summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/SmallPtrSet.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-04-18 10:37:32 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-04-18 10:37:32 +0000
commit94988cb34ce5f3a2a9e560e3eee55f410c7b9ff3 (patch)
tree4f1df9986e0716532d079e5a5e06afdc947001b4 /llvm/lib/Support/SmallPtrSet.cpp
parentb0e978989999ad828b35d67c199fb082ddf6e922 (diff)
downloadbcm5719-llvm-94988cb34ce5f3a2a9e560e3eee55f410c7b9ff3.tar.gz
bcm5719-llvm-94988cb34ce5f3a2a9e560e3eee55f410c7b9ff3.zip
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. llvm-svn: 154996
Diffstat (limited to 'llvm/lib/Support/SmallPtrSet.cpp')
-rw-r--r--llvm/lib/Support/SmallPtrSet.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Support/SmallPtrSet.cpp b/llvm/lib/Support/SmallPtrSet.cpp
index 68d9c29411f..3b53e9ff49f 100644
--- a/llvm/lib/Support/SmallPtrSet.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud