| Index: Source/wtf/Vector.h
|
| diff --git a/Source/wtf/Vector.h b/Source/wtf/Vector.h
|
| index c2ab2c50a694c2ba1c79e857ef6e75a9fc08c713..260bd580f2039e31f0dfdaab1263028f45b372a1 100644
|
| --- a/Source/wtf/Vector.h
|
| +++ b/Source/wtf/Vector.h
|
| @@ -162,7 +162,8 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
|
| template<typename T>
|
| struct VectorCopier<false, T>
|
| {
|
| - static void uninitializedCopy(const T* src, const T* srcEnd, T* dst)
|
| + template<typename U>
|
| + static void uninitializedCopy(const U* src, const U* srcEnd, T* dst)
|
| {
|
| while (src != srcEnd) {
|
| new (NotNull, dst) T(*src);
|
| @@ -179,6 +180,11 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
|
| {
|
| memcpy(dst, src, reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
|
| }
|
| + template<typename U>
|
| + static void uninitializedCopy(const U* src, const U* srcEnd, T* dst)
|
| + {
|
| + VectorCopier<false, T>::uninitializedCopy(src, srcEnd, dst);
|
| + }
|
| };
|
|
|
| template <bool canFillWithMemset, typename T>
|
| @@ -963,8 +969,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
|
| }
|
| RELEASE_ASSERT(newSize >= m_size);
|
| T* dest = end();
|
| - for (size_t i = 0; i < dataSize; ++i)
|
| - new (NotNull, &dest[i]) T(data[i]);
|
| + VectorCopier<VectorTraits<T>::canCopyWithMemcpy, T>::uninitializedCopy(data, &data[dataSize], dest);
|
| m_size = newSize;
|
| }
|
|
|
| @@ -1023,8 +1028,7 @@ static const size_t kInitialVectorSize = WTF_VECTOR_INITIAL_SIZE;
|
| RELEASE_ASSERT(newSize >= m_size);
|
| T* spot = begin() + position;
|
| TypeOperations::moveOverlapping(spot, end(), spot + dataSize);
|
| - for (size_t i = 0; i < dataSize; ++i)
|
| - new (NotNull, &spot[i]) T(data[i]);
|
| + VectorCopier<VectorTraits<T>::canCopyWithMemcpy, T>::uninitializedCopy(data, &data[dataSize], spot);
|
| m_size = newSize;
|
| }
|
|
|
|
|