From 9c24ff3da79c020100a4693db7070db6dc1bfeaf Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 30 Jun 2008 21:45:13 +0000 Subject: [PATCH] Make SmallVector's grow use memcpy in common cases instead of std::uninitialized_copy, which uses memmove. llvm-svn: 52928 --- llvm/include/llvm/ADT/SmallVector.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h index 3d1640cb5710..daf6ee53fcf6 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/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 #include @@ -349,7 +350,11 @@ void SmallVectorImpl::grow(size_t MinSize) { T *NewElts = static_cast(operator new(NewCapacity*sizeof(T))); // Copy the elements over. - std::uninitialized_copy(Begin, End, NewElts); + if (is_class::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);