[Bf-blender-cvs] [8efd997] depsgraph_cleanup: Depsgraph: Remove use of std::hash, we have our own functions for that

Sergey Sharybin noreply at git.blender.org
Thu May 26 13:55:09 CEST 2016


Commit: 8efd997c07806c18e7dd4d2944d9f61b8912b587
Author: Sergey Sharybin
Date:   Thu May 26 13:44:02 2016 +0200
Branches: depsgraph_cleanup
https://developer.blender.org/rB8efd997c07806c18e7dd4d2944d9f61b8912b587

Depsgraph: Remove use of std::hash, we have our own functions for that

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

M	source/blender/depsgraph/intern/nodes/deg_node.h
M	source/blender/depsgraph/intern/nodes/deg_node_component.h
M	source/blender/depsgraph/util/deg_util_hash.h

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

diff --git a/source/blender/depsgraph/intern/nodes/deg_node.h b/source/blender/depsgraph/intern/nodes/deg_node.h
index 4381935..2b45769 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node.h
@@ -166,7 +166,8 @@ struct IDDepsNode : public DepsNode {
 	struct component_key_hash {
 		bool operator() (const ComponentIDKey &key) const
 		{
-			return hash_combine(hash<int>()(key.type), hash<string>()(key.name));
+			return hash_combine(BLI_ghashutil_uinthash(key.type),
+			                    BLI_ghashutil_strhash_p(key.name.c_str()));
 		}
 	};
 
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h
index 92849fb..d6d3a9c 100644
--- a/source/blender/depsgraph/intern/nodes/deg_node_component.h
+++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h
@@ -98,7 +98,8 @@ struct ComponentDepsNode : public DepsNode {
 	struct operation_key_hash {
 		bool operator() (const OperationIDKey &key) const
 		{
-			return hash_combine(hash<int>()(key.opcode), hash<string>()(key.name));
+			return hash_combine(BLI_ghashutil_uinthash(key.opcode),
+			                    BLI_ghashutil_strhash_p(key.name.c_str()));
 		}
 	};
 
diff --git a/source/blender/depsgraph/util/deg_util_hash.h b/source/blender/depsgraph/util/deg_util_hash.h
index c2b1d43..e490be1 100644
--- a/source/blender/depsgraph/util/deg_util_hash.h
+++ b/source/blender/depsgraph/util/deg_util_hash.h
@@ -30,40 +30,12 @@
 
 #pragma once
 
-#if defined(DEG_NO_UNORDERED_MAP)
-#  define DEG_HASH_NAMESPACE_BEGIN
-#  define DEG_HASH_NAMESPACE_END
-#endif
+#include "BLI_utildefines.h"
 
-#if defined(DEG_TR1_UNORDERED_MAP)
-#  include <tr1/unordered_map>
-#  define DEG_HASH_NAMESPACE_BEGIN namespace std { namespace tr1 {
-#  define DEG_HASH_NAMESPACE_END } }
-using std::tr1::hash;
-#endif
-
-#if defined(DEG_STD_UNORDERED_MAP)
-#  include <unordered_map>
-#  define DEG_HASH_NAMESPACE_BEGIN namespace std {
-#  define DEG_HASH_NAMESPACE_END }
-using std::hash;
-#endif
-
-#if defined(DEG_STD_UNORDERED_MAP_IN_TR1_NAMESPACE)
-#  include <unordered_map>
-#  define DEG_HASH_NAMESPACE_BEGIN namespace std { namespace tr1 {
-#  define DEG_HASH_NAMESPACE_END } }
-using std::tr1::hash;
-#endif
-
-#if !defined(DEG_NO_UNORDERED_MAP) && !defined(DEG_TR1_UNORDERED_MAP) && \
-    !defined(DEG_STD_UNORDERED_MAP) && !defined(DEG_STD_UNORDERED_MAP_IN_TR1_NAMESPACE)  // NOLINT
-#  error One of: DEG_NO_UNORDERED_MAP, DEG_TR1_UNORDERED_MAP,\
- DEG_STD_UNORDERED_MAP, DEG_STD_UNORDERED_MAP_IN_TR1_NAMESPACE must be defined!  // NOLINT
-#endif
+#include "BLI_ghash.h"
 
 /* XXX this might require 2 different variants for sizeof(size_t) (32 vs 64 bit) */
-inline size_t hash_combine(size_t hash_a, size_t hash_b)
+BLI_INLINE size_t hash_combine(size_t hash_a, size_t hash_b)
 {
 	return hash_a ^ (hash_b + 0x9e3779b9 + (hash_a << 6) + (hash_a >> 2));
 }




More information about the Bf-blender-cvs mailing list