Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2284)

Unified Diff: Source/wtf/HashFunctions.h

Issue 17583004: Improve WTF::HashTable performance by changing probing method (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/wtf/HashTable.h » ('j') | Source/wtf/HashTable.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/HashFunctions.h
diff --git a/Source/wtf/HashFunctions.h b/Source/wtf/HashFunctions.h
index 75fabcd97ad02cea0bcff9ffbb836e80c7dfb93e..ee842c3f7225416b88712ec2250f2b1e98c3d802 100644
--- a/Source/wtf/HashFunctions.h
+++ b/Source/wtf/HashFunctions.h
@@ -32,57 +32,25 @@ namespace WTF {
template<> struct IntTypes<4> { typedef int32_t SignedType; typedef uint32_t UnsignedType; };
template<> struct IntTypes<8> { typedef int64_t SignedType; typedef uint64_t UnsignedType; };
- // integer hash function
-
- // Thomas Wang's 32 Bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.htm
inline unsigned intHash(uint8_t key8)
{
- unsigned key = key8;
- key += ~(key << 15);
- key ^= (key >> 10);
- key += (key << 3);
- key ^= (key >> 6);
- key += ~(key << 11);
- key ^= (key >> 16);
- return key;
+ return key8;
}
- // Thomas Wang's 32 Bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.htm
inline unsigned intHash(uint16_t key16)
{
- unsigned key = key16;
- key += ~(key << 15);
- key ^= (key >> 10);
- key += (key << 3);
- key ^= (key >> 6);
- key += ~(key << 11);
- key ^= (key >> 16);
- return key;
+ return key16;
}
- // Thomas Wang's 32 Bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.htm
inline unsigned intHash(uint32_t key)
{
- key += ~(key << 15);
- key ^= (key >> 10);
- key += (key << 3);
- key ^= (key >> 6);
- key += ~(key << 11);
- key ^= (key >> 16);
- return key;
+ return key ^ (key >> 16);
}
-
- // Thomas Wang's 64 bit Mix Function: http://www.cris.com/~Ttwang/tech/inthash.htm
+
inline unsigned intHash(uint64_t key)
{
- key += ~(key << 32);
- key ^= (key >> 22);
- key += ~(key << 13);
- key ^= (key >> 8);
- key += (key << 3);
- key ^= (key >> 15);
- key += ~(key << 27);
- key ^= (key >> 31);
+ key ^= key >> 32;
+ key ^= key >> 16;
return static_cast<unsigned>(key);
}
@@ -126,7 +94,9 @@ namespace WTF {
#pragma warning(push)
#pragma warning(disable: 4244) // work around what seems to be a bug in MSVC's conversion warnings
#endif
- return IntHash<uintptr_t>::hash(reinterpret_cast<uintptr_t>(key));
+ uintptr_t keyIntPtr = reinterpret_cast<uintptr_t>(key);
+ keyIntPtr ^= keyIntPtr >> 6;
+ return IntHash<uintptr_t>::hash(keyIntPtr);
#if COMPILER(MSVC)
#pragma warning(pop)
#endif
« no previous file with comments | « no previous file | Source/wtf/HashTable.h » ('j') | Source/wtf/HashTable.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698