diff options
author | Jean-Luc Duprat <jduprat@apple.com> | 2013-03-29 22:07:12 +0000 |
---|---|---|
committer | Jean-Luc Duprat <jduprat@apple.com> | 2013-03-29 22:07:12 +0000 |
commit | e1e9366281a98cd06b61d5d7e136ce2b1a433ba6 (patch) | |
tree | b5e8c95e3df451094d139ea2764dac37dc160756 /include/llvm/ADT/SmallVector.h | |
parent | 4991289b33f04f308bf5495a51518f850aa31cfa (diff) | |
download | llvm-e1e9366281a98cd06b61d5d7e136ce2b1a433ba6.tar.gz llvm-e1e9366281a98cd06b61d5d7e136ce2b1a433ba6.tar.bz2 llvm-e1e9366281a98cd06b61d5d7e136ce2b1a433ba6.tar.xz |
SmallVector and SmallPtrSet allocations now power-of-two aligned.
This time tested on both OSX and Linux.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178377 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/SmallVector.h')
-rw-r--r-- | include/llvm/ADT/SmallVector.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index 9167f87218..7ba0a714bf 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -16,6 +16,7 @@ #include "llvm/Support/AlignOf.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Support/type_traits.h" #include <algorithm> #include <cassert> @@ -267,7 +268,8 @@ template <typename T, bool isPodLike> void SmallVectorTemplateBase<T, isPodLike>::grow(size_t MinSize) { size_t CurCapacity = this->capacity(); size_t CurSize = this->size(); - size_t NewCapacity = 2*CurCapacity + 1; // Always grow, even from zero. + // Always grow, even from zero. + size_t NewCapacity = size_t(NextPowerOf2(CurCapacity+2)); if (NewCapacity < MinSize) NewCapacity = MinSize; T *NewElts = static_cast<T*>(malloc(NewCapacity*sizeof(T))); |