Commit: 7e66a3d78191ce5622a8ab887b33ff19bdbedce0
Author: Sergey Sharybin
Date:   Thu May 26 17:44:59 2016 +0200
Branches: depsgraph_cleanup
https://developer.blender.org/rB7e66a3d78191ce5622a8ab887b33ff19bdbedce0

Depsgraph: Simplify some destructors

===================================================================

M       source/blender/depsgraph/intern/depsgraph.cc
M       source/blender/depsgraph/intern/nodes/deg_node.cc
M       source/blender/depsgraph/intern/nodes/deg_node_component.cc

===================================================================

diff --git a/source/blender/depsgraph/intern/depsgraph.cc 
b/source/blender/depsgraph/intern/depsgraph.cc
index 8207ea6..79fc273 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -249,6 +249,12 @@ DepsNode *Depsgraph::find_node_from_pointer(const 
PointerRNA *ptr,
 
 /* Node Management ---------------------------- */
 
+static void id_node_deleter(void *value)
+{
+       IDDepsNode *id_node = reinterpret_cast<IDDepsNode *>(value);
+       OBJECT_GUARDED_DELETE(id_node, IDDepsNode);
+}
+
 RootDepsNode *Depsgraph::add_root_node()
 {
        if (!root_node) {
@@ -347,12 +353,7 @@ void Depsgraph::remove_id_node(const ID *id)
 
 void Depsgraph::clear_id_nodes()
 {
-       GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, id_hash)
-       {
-               OBJECT_GUARDED_DELETE(id_node, IDDepsNode);
-       }
-       GHASH_FOREACH_END();
-       BLI_ghash_clear(id_hash, NULL, NULL);
+       BLI_ghash_clear(id_hash, NULL, id_node_deleter);
 }
 
 /* Add new relationship between two nodes. */
diff --git a/source/blender/depsgraph/intern/nodes/deg_node.cc 
b/source/blender/depsgraph/intern/nodes/deg_node.cc
index 5e6672d..f8fcec8 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node.cc
@@ -144,26 +144,32 @@ static DepsNodeFactoryImpl<TimeSourceDepsNode> 
DNTI_TIMESOURCE;
 
 static unsigned int id_deps_node_hash_key(const void *key_v)
 {
-    const IDDepsNode::ComponentIDKey *key =
-            reinterpret_cast<const IDDepsNode::ComponentIDKey *>(key_v);
-    return hash_combine(BLI_ghashutil_uinthash(key->type),
-                        BLI_ghashutil_strhash_p(key->name.c_str()));
+       const IDDepsNode::ComponentIDKey *key =
+               reinterpret_cast<const IDDepsNode::ComponentIDKey *>(key_v);
+       return hash_combine(BLI_ghashutil_uinthash(key->type),
+                           BLI_ghashutil_strhash_p(key->name.c_str()));
 }
 
 static bool id_deps_node_hash_key_cmp(const void *a, const void *b)
 {
-    const IDDepsNode::ComponentIDKey *key_a =
-            reinterpret_cast<const IDDepsNode::ComponentIDKey *>(a);
-    const IDDepsNode::ComponentIDKey *key_b =
-            reinterpret_cast<const IDDepsNode::ComponentIDKey *>(b);
-    return !(*key_a == *key_b);
+       const IDDepsNode::ComponentIDKey *key_a =
+               reinterpret_cast<const IDDepsNode::ComponentIDKey *>(a);
+       const IDDepsNode::ComponentIDKey *key_b =
+               reinterpret_cast<const IDDepsNode::ComponentIDKey *>(b);
+       return !(*key_a == *key_b);
 }
 
 static void id_deps_node_hash_key_free(void *key_v)
 {
-    typedef IDDepsNode::ComponentIDKey ComponentIDKey;
-    ComponentIDKey *key = reinterpret_cast<ComponentIDKey *>(key_v);
-    OBJECT_GUARDED_DELETE(key, ComponentIDKey);
+       typedef IDDepsNode::ComponentIDKey ComponentIDKey;
+       ComponentIDKey *key = reinterpret_cast<ComponentIDKey *>(key_v);
+       OBJECT_GUARDED_DELETE(key, ComponentIDKey);
+}
+
+static void id_deps_node_hash_value_free(void *value_v)
+{
+       ComponentDepsNode *comp_node = reinterpret_cast<ComponentDepsNode 
*>(value_v);
+       OBJECT_GUARDED_DELETE(comp_node, ComponentDepsNode);
 }
 
 /* Initialize 'id' node - from pointer data given. */
@@ -228,12 +234,9 @@ void IDDepsNode::remove_component(eDepsNode_Type type, 
const string &name)
 
 void IDDepsNode::clear_components()
 {
-       GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, components)
-       {
-               OBJECT_GUARDED_DELETE(comp_node, ComponentDepsNode);
-       }
-       GHASH_FOREACH_END();
-       BLI_ghash_clear(components, id_deps_node_hash_key_free, NULL);
+       BLI_ghash_clear(components,
+                       id_deps_node_hash_key_free,
+                       id_deps_node_hash_value_free);
 }
 
 void IDDepsNode::tag_update(Depsgraph *graph)
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc 
b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
index 2757116..ad77117 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc
@@ -77,6 +77,12 @@ static void comp_node_hash_key_free(void *key_v)
        OBJECT_GUARDED_DELETE(key, OperationIDKey);
 }
 
+static void comp_node_hash_value_free(void *value_v)
+{
+       OperationDepsNode *op_node = reinterpret_cast<OperationDepsNode 
*>(value_v);
+       OBJECT_GUARDED_DELETE(op_node, OperationDepsNode);
+}
+
 ComponentDepsNode::ComponentDepsNode() :
     entry_operation(NULL),
     exit_operation(NULL),
@@ -197,12 +203,9 @@ void 
ComponentDepsNode::remove_operation(eDepsOperation_Code opcode, const strin
 
 void ComponentDepsNode::clear_operations()
 {
-       GHASH_FOREACH_BEGIN(OperationDepsNode *, op_node, operations)
-       {
-               OBJECT_GUARDED_DELETE(op_node, OperationDepsNode);
-       }
-       GHASH_FOREACH_END();
-       BLI_ghash_clear(operations, comp_node_hash_key_free, NULL);
+       BLI_ghash_clear(operations,
+                       comp_node_hash_key_free,
+                       comp_node_hash_value_free);
 }
 
 void ComponentDepsNode::tag_update(Depsgraph *graph)

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to