From df495e758d0fabc74e8ca5bbf9dc4d71af3ac63c Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 18 Aug 2020 13:04:28 +0200 Subject: Cleanup: use Span instead of separate pointer and length Reviewers: sergey Differential Revision: https://developer.blender.org/D8605 --- .../depsgraph/intern/builder/pipeline_from_ids.cc | 45 ++++++++++------------ .../depsgraph/intern/builder/pipeline_from_ids.h | 5 +-- source/blender/depsgraph/intern/depsgraph_build.cc | 3 +- 3 files changed, 25 insertions(+), 28 deletions(-) (limited to 'source/blender/depsgraph') diff --git a/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc b/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc index e44f554f197..c42bccaadec 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc +++ b/source/blender/depsgraph/intern/builder/pipeline_from_ids.cc @@ -32,11 +32,9 @@ namespace { class DepsgraphFromIDsFilter { public: - DepsgraphFromIDsFilter(ID **ids, const int num_ids) + DepsgraphFromIDsFilter(Span ids) { - for (int i = 0; i < num_ids; ++i) { - ids_.add(ids[i]); - } + ids_.add_multiple(ids); } bool contains(ID *id) @@ -50,9 +48,11 @@ class DepsgraphFromIDsFilter { class DepsgraphFromIDsNodeBuilder : public DepsgraphNodeBuilder { public: - DepsgraphFromIDsNodeBuilder( - Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache, ID **ids, const int num_ids) - : DepsgraphNodeBuilder(bmain, graph, cache), filter_(ids, num_ids) + DepsgraphFromIDsNodeBuilder(Main *bmain, + Depsgraph *graph, + DepsgraphBuilderCache *cache, + Span ids) + : DepsgraphNodeBuilder(bmain, graph, cache), filter_(ids) { } @@ -81,9 +81,11 @@ class DepsgraphFromIDsNodeBuilder : public DepsgraphNodeBuilder { class DepsgraphFromIDsRelationBuilder : public DepsgraphRelationBuilder { public: - DepsgraphFromIDsRelationBuilder( - Main *bmain, Depsgraph *graph, DepsgraphBuilderCache *cache, ID **ids, const int num_ids) - : DepsgraphRelationBuilder(bmain, graph, cache), filter_(ids, num_ids) + DepsgraphFromIDsRelationBuilder(Main *bmain, + Depsgraph *graph, + DepsgraphBuilderCache *cache, + Span ids) + : DepsgraphRelationBuilder(bmain, graph, cache), filter_(ids) { } @@ -112,41 +114,36 @@ class DepsgraphFromIDsRelationBuilder : public DepsgraphRelationBuilder { } // namespace -FromIDsBuilderPipeline::FromIDsBuilderPipeline(::Depsgraph *graph, - Main *bmain, - Scene *scene, - ViewLayer *view_layer, - ID **ids, - const int num_ids) - : AbstractBuilderPipeline(graph, bmain, scene, view_layer), ids_(ids), num_ids_(num_ids) +FromIDsBuilderPipeline::FromIDsBuilderPipeline( + ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, Span ids) + : AbstractBuilderPipeline(graph, bmain, scene, view_layer), ids_(ids) { } unique_ptr FromIDsBuilderPipeline::construct_node_builder() { - return std::make_unique( - bmain_, deg_graph_, &builder_cache_, ids_, num_ids_); + return std::make_unique(bmain_, deg_graph_, &builder_cache_, ids_); } unique_ptr FromIDsBuilderPipeline::construct_relation_builder() { return std::make_unique( - bmain_, deg_graph_, &builder_cache_, ids_, num_ids_); + bmain_, deg_graph_, &builder_cache_, ids_); } void FromIDsBuilderPipeline::build_nodes(DepsgraphNodeBuilder &node_builder) { node_builder.build_view_layer(scene_, view_layer_, DEG_ID_LINKED_DIRECTLY); - for (int i = 0; i < num_ids_; ++i) { - node_builder.build_id(ids_[i]); + for (ID *id : ids_) { + node_builder.build_id(id); } } void FromIDsBuilderPipeline::build_relations(DepsgraphRelationBuilder &relation_builder) { relation_builder.build_view_layer(scene_, view_layer_, DEG_ID_LINKED_DIRECTLY); - for (int i = 0; i < num_ids_; ++i) { - relation_builder.build_id(ids_[i]); + for (ID *id : ids_) { + relation_builder.build_id(id); } } diff --git a/source/blender/depsgraph/intern/builder/pipeline_from_ids.h b/source/blender/depsgraph/intern/builder/pipeline_from_ids.h index 4a507f2c728..a52a9f6f252 100644 --- a/source/blender/depsgraph/intern/builder/pipeline_from_ids.h +++ b/source/blender/depsgraph/intern/builder/pipeline_from_ids.h @@ -44,7 +44,7 @@ namespace deg { class FromIDsBuilderPipeline : public AbstractBuilderPipeline { public: FromIDsBuilderPipeline( - ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, ID **ids, int num_ids); + ::Depsgraph *graph, Main *bmain, Scene *scene, ViewLayer *view_layer, Span ids); protected: virtual unique_ptr construct_node_builder() override; @@ -54,8 +54,7 @@ class FromIDsBuilderPipeline : public AbstractBuilderPipeline { virtual void build_relations(DepsgraphRelationBuilder &relation_builder) override; private: - ID **ids_; - const int num_ids_; + Span ids_; }; } // namespace deg diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index 230c59bd651..dc49534eb2d 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -251,7 +251,8 @@ void DEG_graph_build_from_ids(Depsgraph *graph, ID **ids, const int num_ids) { - deg::FromIDsBuilderPipeline builder(graph, bmain, scene, view_layer, ids, num_ids); + deg::FromIDsBuilderPipeline builder( + graph, bmain, scene, view_layer, blender::Span(ids, num_ids)); builder.build(); } -- cgit v1.2.3