[llvm-commits] [llvm] r52928 - /llvm/trunk/include/llvm/ADT/SmallVector.h
Dan Gohman
gohman at apple.com
Mon Jun 30 14:45:14 PDT 2008
Author: djg
Date: Mon Jun 30 16:45:13 2008
New Revision: 52928
URL: http://llvm.org/viewvc/llvm-project?rev=52928&view=rev
Log:
Make SmallVector's grow use memcpy in common cases
instead of std::uninitialized_copy, which uses memmove.
Modified:
llvm/trunk/include/llvm/ADT/SmallVector.h
Modified: llvm/trunk/include/llvm/ADT/SmallVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/SmallVector.h?rev=52928&r1=52927&r2=52928&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/SmallVector.h (original)
+++ llvm/trunk/include/llvm/ADT/SmallVector.h Mon Jun 30 16:45:13 2008
@@ -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 @@
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);
More information about the llvm-commits
mailing list