[Bf-blender-cvs] [26a0007] depsgraph_refactor: Depsgraph: Use BLI_gset_add() instead of BLI_gset_insert() to avoid duplicate entries in set

Joshua Leung noreply at git.blender.org
Mon Jan 26 12:28:31 CET 2015


Commit: 26a00078e0958c99793f4f8e5fdfc4e57d65f151
Author: Joshua Leung
Date:   Tue Jan 27 00:28:13 2015 +1300
Branches: depsgraph_refactor
https://developer.blender.org/rB26a00078e0958c99793f4f8e5fdfc4e57d65f151

Depsgraph: Use BLI_gset_add() instead of BLI_gset_insert() to avoid duplicate entries in set

So it turns out that using BLI_gset_insert() will just cause the ghash-set
implementation to blindly add duplicate entries if the key already exists
in the hashtable - not exactly what we want, as that kindof violates the
whole point of such data structures.

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

M	source/blender/depsgraph/intern/depsgraph_build_relations.cpp

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

diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
index 2e4f0a9..8b4e97a 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
@@ -200,9 +200,9 @@ void DepsgraphRelationBuilder::RootPChanMap::print_debug()
 void DepsgraphRelationBuilder::RootPChanMap::add_bone(const char *bone, const char *root)
 {
 	if (BLI_ghash_haskey(m_map, bone)) {
-		/* add new entry */
+		/* add new entry, but only add the root if it doesn't already exist in there */
 		GSet *values = (GSet *)BLI_ghash_lookup(m_map, bone);
-		BLI_gset_insert(values, (void *)root);
+		BLI_gset_add(values, (void *)root);
 	}
 	else {
 		/* create new set and mapping */




More information about the Bf-blender-cvs mailing list