diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Support/StringMap.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Support/StringMap.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/contrib/llvm-project/llvm/lib/Support/StringMap.cpp b/contrib/llvm-project/llvm/lib/Support/StringMap.cpp index 9b2f96fca2cd..67c05a87959c 100644 --- a/contrib/llvm-project/llvm/lib/Support/StringMap.cpp +++ b/contrib/llvm-project/llvm/lib/Support/StringMap.cpp @@ -11,8 +11,9 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/StringMap.h" -#include "llvm/Support/DJB.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Support/ReverseIteration.h" +#include "llvm/Support/xxhash.h" using namespace llvm; @@ -84,7 +85,9 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) { // Hash table unallocated so far? if (NumBuckets == 0) init(16); - unsigned FullHashValue = djbHash(Name, 0); + unsigned FullHashValue = xxh3_64bits(Name); + if (shouldReverseIterate()) + FullHashValue = ~FullHashValue; unsigned BucketNo = FullHashValue & (NumBuckets - 1); unsigned *HashTable = getHashTable(TheTable, NumBuckets); @@ -139,7 +142,9 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) { int StringMapImpl::FindKey(StringRef Key) const { if (NumBuckets == 0) return -1; // Really empty table? - unsigned FullHashValue = djbHash(Key, 0); + unsigned FullHashValue = xxh3_64bits(Key); + if (shouldReverseIterate()) + FullHashValue = ~FullHashValue; unsigned BucketNo = FullHashValue & (NumBuckets - 1); unsigned *HashTable = getHashTable(TheTable, NumBuckets); |