[Bf-blender-cvs] [60dada5] depsgraph_cleanup: Depsgraph: Use gset instead of unordreed_unordered_set
Sergey Sharybin
noreply at git.blender.org
Thu May 26 18:04:04 CEST 2016
Commit: 60dada5492dcf3e10c20bee64784836b5c5c0168
Author: Sergey Sharybin
Date: Thu May 26 15:56:40 2016 +0200
Branches: depsgraph_cleanup
https://developer.blender.org/rB60dada5492dcf3e10c20bee64784836b5c5c0168
Depsgraph: Use gset instead of unordreed_unordered_set
===================================================================
M source/blender/depsgraph/intern/depsgraph.cc
M source/blender/depsgraph/intern/depsgraph.h
M source/blender/depsgraph/intern/depsgraph_build.cc
M source/blender/depsgraph/intern/depsgraph_eval.cc
M source/blender/depsgraph/intern/eval/deg_eval.cc
M source/blender/depsgraph/intern/eval/deg_eval_flush.cc
===================================================================
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index b3c26b9..3739b08 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -75,6 +75,8 @@ Depsgraph::Depsgraph()
{
BLI_spin_init(&lock);
id_hash = BLI_ghash_ptr_new("depsgraph id hash");
+ subgraphs = BLI_gset_ptr_new("depsgraph subgraphs");
+ entry_tags = BLI_gset_ptr_new("depsgraph entry_tags");
}
Depsgraph::~Depsgraph()
@@ -83,6 +85,8 @@ Depsgraph::~Depsgraph()
clear_id_nodes();
clear_subgraph_nodes();
BLI_ghash_free(id_hash, NULL, NULL);
+ BLI_gset_free(subgraphs, NULL);
+ BLI_gset_free(entry_tags, NULL);
if (this->root_node != NULL) {
OBJECT_GUARDED_DELETE(this->root_node, RootDepsNode);
}
@@ -282,7 +286,7 @@ SubgraphDepsNode *Depsgraph::add_subgraph_node(const ID *id)
(SubgraphDepsNode *)factory->create_node(id, "", id->name + 2);
/* Add to subnodes list. */
- this->subgraphs.insert(subgraph_node);
+ BLI_gset_insert(subgraphs, subgraph_node);
/* if there's an ID associated, add to ID-nodes lookup too */
if (id) {
@@ -299,16 +303,18 @@ SubgraphDepsNode *Depsgraph::add_subgraph_node(const ID *id)
void Depsgraph::remove_subgraph_node(SubgraphDepsNode *subgraph_node)
{
- subgraphs.erase(subgraph_node);
+ BLI_gset_remove(subgraphs, subgraph_node, NULL);
OBJECT_GUARDED_DELETE(subgraph_node, SubgraphDepsNode);
}
void Depsgraph::clear_subgraph_nodes()
{
- foreach (SubgraphDepsNode *subgraph_node, subgraphs) {
+ GSetIterator gs_iter;
+ GSET_ITER (gs_iter, subgraphs) {
+ SubgraphDepsNode *subgraph_node = reinterpret_cast<SubgraphDepsNode *>(BLI_gsetIterator_getKey(&gs_iter));
OBJECT_GUARDED_DELETE(subgraph_node, SubgraphDepsNode);
}
- subgraphs.clear();
+ BLI_gset_clear(subgraphs, NULL);
}
IDDepsNode *Depsgraph::find_id_node(const ID *id) const
@@ -452,7 +458,7 @@ void Depsgraph::add_entry_tag(OperationDepsNode *node)
/* Add to graph-level set of directly modified nodes to start searching from.
* NOTE: this is necessary since we have several thousand nodes to play with...
*/
- this->entry_tags.insert(node);
+ BLI_gset_insert(entry_tags, node);
}
void Depsgraph::clear_all_nodes()
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index cd07f3f..5064d18 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -44,6 +44,7 @@
struct ID;
struct GHash;
+struct GSet;
struct PointerRNA;
struct PropertyRNA;
@@ -96,8 +97,6 @@ struct DepsRelation {
/* Dependency Graph object */
struct Depsgraph {
- typedef unordered_set<SubgraphDepsNode *> Subgraphs;
- typedef unordered_set<OperationDepsNode *> EntryTags;
typedef vector<OperationDepsNode *> OperationNodes;
Depsgraph();
@@ -170,7 +169,7 @@ struct Depsgraph {
RootDepsNode *root_node;
/* Subgraphs referenced in tree. */
- Subgraphs subgraphs;
+ GSet *subgraphs;
/* Indicates whether relations needs to be updated. */
bool need_update;
@@ -178,7 +177,7 @@ struct Depsgraph {
/* Quick-Access Temp Data ............. */
/* Nodes which have been tagged as "directly modified". */
- EntryTags entry_tags;
+ GSet *entry_tags;
/* Convenience Data ................... */
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 4956806..b5c4085 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -259,7 +259,7 @@ void DEG_scene_relations_update(Main *bmain, Scene *scene)
/* Clear all previous nodes and operations. */
graph->clear_all_nodes();
graph->operations.clear();
- graph->entry_tags.clear();
+ BLI_gset_clear(graph->entry_tags, NULL);
/* Build new nodes and relations. */
DEG_graph_build_from_scene(reinterpret_cast< ::Depsgraph * >(graph),
diff --git a/source/blender/depsgraph/intern/depsgraph_eval.cc b/source/blender/depsgraph/intern/depsgraph_eval.cc
index 588b4a4..2668646 100644
--- a/source/blender/depsgraph/intern/depsgraph_eval.cc
+++ b/source/blender/depsgraph/intern/depsgraph_eval.cc
@@ -147,5 +147,5 @@ void DEG_evaluate_on_framechange(EvaluationContext *eval_ctx,
bool DEG_needs_eval(Depsgraph *graph)
{
DEG::Depsgraph *deg_graph = reinterpret_cast<DEG::Depsgraph *>(graph);
- return deg_graph->entry_tags.size() != 0;
+ return BLI_gset_size(deg_graph->entry_tags) != 0;
}
diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc
index ecec871..21742c0 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval.cc
@@ -356,7 +356,7 @@ void deg_evaluate_on_refresh(EvaluationContext *eval_ctx,
// TODO: this needs both main and scene access...
/* Nothing to update, early out. */
- if (graph->entry_tags.size() == 0) {
+ if (BLI_gset_size(graph->entry_tags) == 0) {
return;
}
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
index cb2cb34..28502b4 100644
--- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
+++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc
@@ -95,7 +95,7 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph)
}
/* Nothing to update, early out. */
- if (graph->entry_tags.size() == 0) {
+ if (BLI_gset_size(graph->entry_tags) == 0) {
return;
}
@@ -117,7 +117,9 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph)
* NOTE: Count how many nodes we need to handle - entry nodes may be
* component nodes which don't count for this purpose!
*/
- foreach (OperationDepsNode *node, graph->entry_tags) {
+ GSetIterator gs_iter;
+ GSET_ITER (gs_iter, graph->entry_tags) {
+ OperationDepsNode *node = reinterpret_cast<OperationDepsNode *>(BLI_gsetIterator_getKey(&gs_iter));
IDDepsNode *id_node = node->owner->owner;
queue.push(node);
if (id_node->done == 0) {
@@ -203,7 +205,7 @@ void deg_graph_clear_tags(Depsgraph *graph)
const bool do_threads = num_operations > 256;
BLI_task_parallel_range(0, num_operations, graph, graph_clear_func, do_threads);
/* Clear any entry tags which haven't been flushed. */
- graph->entry_tags.clear();
+ BLI_gset_clear(graph->entry_tags, NULL);
}
} // namespace DEG
More information about the Bf-blender-cvs
mailing list