We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0269d7f commit 944120bCopy full SHA for 944120b
lib/Common/DataStructures/SizePolicy.h
@@ -32,6 +32,13 @@ struct PowerOf2Policy
32
inline static hash_t GetBucket(hash_t hashCode, uint size, int modFunctionIndex)
33
{
34
AssertMsg(Math::IsPow2(size) && size > 1, "Size is not a power of 2.");
35
+
36
+ // we often deal with keys that differ in higher bits only, so smudge the entropy down a little
37
+ // we do not need a perfect avalanche here, since this is for a hashtable lookup
38
+ // the following is sufficient and reasonably cheap
39
+ hashCode ^= (uint)hashCode >> 15;
40
+ hashCode ^= (uint)hashCode >> 7;
41
42
hash_t targetBucket = hashCode & (size-1);
43
return targetBucket;
44
}
0 commit comments