diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-09-02 21:17:18 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2024-01-07 23:04:38 +0000 |
commit | 0e1e0ce556810ad5f9d45485e686f0653530516c (patch) | |
tree | ab02ce7c4fafc0518430e9cec77d41201bce23f0 /contrib/llvm-project/llvm/lib/Support/StringMap.cpp | |
parent | c3eb0b7c19221f3a2133ab14d3ffffa61ec0c4bc (diff) |
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); |