diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-04-18 10:37:32 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-04-18 10:37:32 +0000 |
commit | 4bb87cbac50098acc6816390c00fad419d3434fc (patch) | |
tree | b3bbab8a00d1dfb1ba056988e41790c5ce6d7895 /lib | |
parent | 9a1484165cd7cc3b95f5f65f845257c44f55a5b3 (diff) | |
download | external_llvm-4bb87cbac50098acc6816390c00fad419d3434fc.zip external_llvm-4bb87cbac50098acc6816390c00fad419d3434fc.tar.gz external_llvm-4bb87cbac50098acc6816390c00fad419d3434fc.tar.bz2 |
SmallPtrSet: Reuse DenseMapInfo's pointer hash function instead of inventing a bad one ourselves.
DenseMap's hash function uses slightly more entropy and reduces hash collisions
significantly. I also experimented with Hashing.h, but it didn't gave a lot of
improvement while being much more expensive to compute.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154996 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Support/SmallPtrSet.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Support/SmallPtrSet.cpp b/lib/Support/SmallPtrSet.cpp index 68d9c29..3b53e9f 100644 --- a/lib/Support/SmallPtrSet.cpp +++ b/lib/Support/SmallPtrSet.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/DenseMapInfo.h" #include "llvm/Support/MathExtras.h" #include <algorithm> #include <cstdlib> @@ -102,7 +103,7 @@ bool SmallPtrSetImpl::erase_imp(const void * Ptr) { } const void * const *SmallPtrSetImpl::FindBucketFor(const void *Ptr) const { - unsigned Bucket = Hash(Ptr); + unsigned Bucket = DenseMapInfo<void *>::getHashValue(Ptr) & (CurArraySize-1); unsigned ArraySize = CurArraySize; unsigned ProbeAmt = 1; const void *const *Array = CurArray; |