From 99112c6b193c54409e2a3a5ea76c3759d5c1244c Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Wed, 24 Oct 2012 18:50:44 +0000 Subject: Improve DenseMap checks for power of 2 growth. Thanks for the tip Jakob git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166609 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/DenseMap.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'include/llvm/ADT/DenseMap.h') diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h index ce07f8e9c5..ac4bdbd126 100644 --- a/include/llvm/ADT/DenseMap.h +++ b/include/llvm/ADT/DenseMap.h @@ -600,8 +600,7 @@ public: unsigned OldNumBuckets = NumBuckets; BucketT *OldBuckets = Buckets; - AtLeast = isPowerOf2_32(AtLeast) ? AtLeast : NextPowerOf2(AtLeast); - allocateBuckets(std::max(64, AtLeast)); + allocateBuckets(std::max(64, NextPowerOf2(AtLeast-1))); assert(Buckets); if (!OldBuckets) { this->BaseT::initEmpty(); @@ -827,10 +826,8 @@ public: } void grow(unsigned AtLeast) { - if (AtLeast >= InlineBuckets) { - AtLeast = isPowerOf2_32(AtLeast) ? AtLeast : NextPowerOf2(AtLeast); - AtLeast = std::max(64, AtLeast); - } + if (AtLeast >= InlineBuckets) + AtLeast = std::max(64, NextPowerOf2(AtLeast-1)); if (Small) { if (AtLeast < InlineBuckets) -- cgit v1.2.3-18-g5258