diff options
author | Dan Gohman <gohman@apple.com> | 2008-06-30 21:45:13 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-06-30 21:45:13 +0000 |
commit | f4d7708972370bdd438830e50594b90a36bb6f76 (patch) | |
tree | 8e7da5e30cce4e91f21174ff930dacee2890f86c /include/llvm/ADT/SmallVector.h | |
parent | 7c6618926a9036fccc44fc58e0e0f47042904e7c (diff) | |
download | llvm-f4d7708972370bdd438830e50594b90a36bb6f76.tar.gz llvm-f4d7708972370bdd438830e50594b90a36bb6f76.tar.bz2 llvm-f4d7708972370bdd438830e50594b90a36bb6f76.tar.xz |
Make SmallVector's grow use memcpy in common cases
instead of std::uninitialized_copy, which uses memmove.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52928 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/SmallVector.h')
-rw-r--r-- | include/llvm/ADT/SmallVector.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index 3d1640cb57..daf6ee53fc 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -15,6 +15,7 @@ #define LLVM_ADT_SMALLVECTOR_H #include "llvm/ADT/iterator.h" +#include "llvm/Support/type_traits.h" #include <algorithm> #include <memory> @@ -349,7 +350,11 @@ void SmallVectorImpl<T>::grow(size_t MinSize) { T *NewElts = static_cast<T*>(operator new(NewCapacity*sizeof(T))); // Copy the elements over. - std::uninitialized_copy(Begin, End, NewElts); + if (is_class<T>::value) + std::uninitialized_copy(Begin, End, NewElts); + else + // Use memcpy for PODs (std::uninitialized_copy optimizes to memmove). + memcpy(NewElts, Begin, CurSize * sizeof(T)); // Destroy the original elements. destroy_range(Begin, End); |