diff options
author | Pete Cooper <peter_cooper@apple.com> | 2012-10-23 19:34:36 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2012-10-23 19:34:36 +0000 |
commit | 41ef09a4b56f8dcd2a2b234a61a5fdf7388cb472 (patch) | |
tree | 6f1a112ca45b767cb0d78e33fd8b9bc5758e3acf | |
parent | 8ba353da398116cc8b294c3e7a2f9467f3c61b14 (diff) | |
download | bcm5719-llvm-41ef09a4b56f8dcd2a2b234a61a5fdf7388cb472.tar.gz bcm5719-llvm-41ef09a4b56f8dcd2a2b234a61a5fdf7388cb472.zip |
Change DenseMap to use a power of 2 growth if one is given instead of the next power of 2. This was causing DenseMaps to grow 4x instead of 2x. I'll keep an eye on the buildbots as this could impact performance
llvm-svn: 166493
-rw-r--r-- | llvm/include/llvm/ADT/DenseMap.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h index 0ae54f42926..ce07f8e9c52 100644 --- a/llvm/include/llvm/ADT/DenseMap.h +++ b/llvm/include/llvm/ADT/DenseMap.h @@ -420,7 +420,7 @@ private: NumBuckets = getNumBuckets(); } if (NumBuckets-(NewNumEntries+getNumTombstones()) <= NumBuckets/8) { - this->grow(NumBuckets); + this->grow(NumBuckets * 2); LookupBucketFor(Key, TheBucket); } assert(TheBucket); @@ -600,7 +600,8 @@ public: unsigned OldNumBuckets = NumBuckets; BucketT *OldBuckets = Buckets; - allocateBuckets(std::max<unsigned>(64, NextPowerOf2(AtLeast))); + AtLeast = isPowerOf2_32(AtLeast) ? AtLeast : NextPowerOf2(AtLeast); + allocateBuckets(std::max<unsigned>(64, AtLeast)); assert(Buckets); if (!OldBuckets) { this->BaseT::initEmpty(); @@ -826,8 +827,10 @@ public: } void grow(unsigned AtLeast) { - if (AtLeast >= InlineBuckets) - AtLeast = std::max<unsigned>(64, NextPowerOf2(AtLeast)); + if (AtLeast >= InlineBuckets) { + AtLeast = isPowerOf2_32(AtLeast) ? AtLeast : NextPowerOf2(AtLeast); + AtLeast = std::max<unsigned>(64, AtLeast); + } if (Small) { if (AtLeast < InlineBuckets) |