Added ImmutableMap constructor that accepts a const TreeTy*.
[oota-llvm.git] / include / llvm / ADT / SmallVector.h
index 3d1640cb5710ad6d2587aee1a31220b22d5e7e95..d98d40a3f391c81a9ea4613debd3acb8cc133f87 100644 (file)
@@ -15,7 +15,9 @@
 #define LLVM_ADT_SMALLVECTOR_H
 
 #include "llvm/ADT/iterator.h"
+#include "llvm/Support/type_traits.h"
 #include <algorithm>
+#include <cstring>
 #include <memory>
 
 #ifdef _MSC_VER
@@ -84,7 +86,7 @@ public:
 
     // If this wasn't grown from the inline copy, deallocate the old space.
     if (!isSmall())
-      operator delete(static_cast<void*>(Begin));
+      operator delete(Begin);
   }
   
   typedef size_t size_type;
@@ -349,14 +351,18 @@ 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);
   
   // If this wasn't grown from the inline copy, deallocate the old space.
   if (!isSmall())
-    operator delete(static_cast<void*>(Begin));
+    operator delete(Begin);
   
   Begin = NewElts;
   End = NewElts+CurSize;