Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-04-25 21:06:36 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-04-25 21:06:36 +0400
commita66ae2b4ae433636b6d5fdd0aaf126b595b5faba (patch)
tree37538aef83b69d922d6d984e51f0d73f6f436317 /source/blender/blenkernel/intern/treehash.c
parenta34a65314c82eb4fc34cd6b922e40b19cece5ade (diff)
Outliner: avoid using bitshift when hashing (which could use negative numbers)
Diffstat (limited to 'source/blender/blenkernel/intern/treehash.c')
-rw-r--r--source/blender/blenkernel/intern/treehash.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/treehash.c b/source/blender/blenkernel/intern/treehash.c
index eda78d6c72e..fb55e3d2137 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)