Make SmallVector's grow use memcpy in common cases

instead of std::uninitialized_copy, which uses memmove.

llvm-svn: 52928
This commit is contained in:
Dan Gohman 2008-06-30 21:45:13 +00:00
parent 2b11690e9f
commit 9c24ff3da7
1 changed files with 6 additions and 1 deletions

View File

@ -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);