[Bf-blender-cvs] [a66ae2b] master: Outliner: avoid using bitshift when hashing (which could use negative numbers)

Campbell Barton noreply at git.blender.org
Fri Apr 25 19:15:51 CEST 2014


Commit: a66ae2b4ae433636b6d5fdd0aaf126b595b5faba
Author: Campbell Barton
Date:   Sat Apr 26 03:06:36 2014 +1000
https://developer.blender.org/rBa66ae2b4ae433636b6d5fdd0aaf126b595b5faba

Outliner: avoid using bitshift when hashing (which could use negative numbers)

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

M	source/blender/blenkernel/intern/treehash.c

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

diff --git a/source/blender/blenkernel/intern/treehash.c b/source/blender/blenkernel/intern/treehash.c
index eda78d6..fb55e3d 100644
--- a/source/blender/blenkernel/intern/treehash.c
+++ b/source/blender/blenkernel/intern/treehash.c
@@ -76,11 +76,19 @@ static void tse_group_free(TseGroup *tse_group)
 static unsigned int tse_hash(const void *ptr)
 {
 	const TreeStoreElem *tse = ptr;
-	unsigned int hash;
+	union {
+		short        h_pair[2];
+		unsigned int u_int;
+	} hash;
+
 	BLI_assert(tse->type || !tse->nr);
-	hash = BLI_ghashutil_inthash((tse->nr << 16) + tse->type);
-	hash ^= BLI_ghashutil_ptrhash(tse->id);
-	return hash;
+
+	hash.h_pair[0] = tse->type;
+	hash.h_pair[1] = tse->nr;
+
+	hash.u_int ^= BLI_ghashutil_ptrhash(tse->id);
+
+	return hash.u_int;
 }
 
 static int tse_cmp(const void *a, const void *b)




More information about the Bf-blender-cvs mailing list