Index: third_party/WebKit/Source/wtf/Vector.h |
diff --git a/third_party/WebKit/Source/wtf/Vector.h b/third_party/WebKit/Source/wtf/Vector.h |
index b2f2954352d50616b92000f0d3159109b7dd6f35..46ada79a5277958559f0e509c9e7d98280651cfe 100644 |
--- a/third_party/WebKit/Source/wtf/Vector.h |
+++ b/third_party/WebKit/Source/wtf/Vector.h |
@@ -127,16 +127,16 @@ struct VectorMover; |
template <typename T> |
struct VectorMover<false, T> { |
- static void move(const T* src, const T* srcEnd, T* dst) |
+ static void move(T* src, T* srcEnd, T* dst) |
{ |
while (src != srcEnd) { |
- new (NotNull, dst) T(*src); |
+ new (NotNull, dst) T(std::move(*src)); |
src->~T(); |
++dst; |
++src; |
} |
} |
- static void moveOverlapping(const T* src, const T* srcEnd, T* dst) |
+ static void moveOverlapping(T* src, T* srcEnd, T* dst) |
{ |
if (src > dst) { |
move(src, srcEnd, dst); |
@@ -145,7 +145,7 @@ struct VectorMover<false, T> { |
while (src != srcEnd) { |
--srcEnd; |
--dstEnd; |
- new (NotNull, dstEnd) T(*srcEnd); |
+ new (NotNull, dstEnd) T(std::move(*srcEnd)); |
srcEnd->~T(); |
} |
} |
@@ -267,12 +267,12 @@ struct VectorTypeOperations { |
VectorInitializer<VectorTraits<T>::canInitializeWithMemset, T>::initialize(begin, end); |
} |
- static void move(const T* src, const T* srcEnd, T* dst) |
+ static void move(T* src, T* srcEnd, T* dst) |
{ |
VectorMover<VectorTraits<T>::canMoveWithMemcpy, T>::move(src, srcEnd, dst); |
} |
- static void moveOverlapping(const T* src, const T* srcEnd, T* dst) |
+ static void moveOverlapping(T* src, T* srcEnd, T* dst) |
{ |
VectorMover<VectorTraits<T>::canMoveWithMemcpy, T>::moveOverlapping(src, srcEnd, dst); |
} |
@@ -745,16 +745,16 @@ public: |
void clear() { shrinkCapacity(0); } |
template <typename U> void append(const U*, size_t); |
- template <typename U> void append(const U&); |
- template <typename U> void uncheckedAppend(const U& val); |
+ template <typename U> void append(U&&); |
+ template <typename U> void uncheckedAppend(U&& val); |
template <typename U, size_t otherCapacity, typename V> void appendVector(const Vector<U, otherCapacity, V>&); |
template <typename U> void insert(size_t position, const U*, size_t); |
- template <typename U> void insert(size_t position, const U&); |
+ template <typename U> void insert(size_t position, U&&); |
template <typename U, size_t c, typename V> void insert(size_t position, const Vector<U, c, V>&); |
template <typename U> void prepend(const U*, size_t); |
- template <typename U> void prepend(const U&); |
+ template <typename U> void prepend(U&&); |
template <typename U, size_t c, typename V> void prepend(const Vector<U, c, V>&); |
void remove(size_t position); |
@@ -795,10 +795,15 @@ protected: |
private: |
void expandCapacity(size_t newMinCapacity); |
- const T* expandCapacity(size_t newMinCapacity, const T*); |
+ T* expandCapacity(size_t newMinCapacity, T*); |
+ T* expandCapacity(size_t newMinCapacity, const T* data) |
+ { |
+ return expandCapacity(newMinCapacity, const_cast<T*>(data)); |
+ } |
+ |
template <typename U> U* expandCapacity(size_t newMinCapacity, U*); |
void shrinkCapacity(size_t newCapacity); |
- template <typename U> void appendSlowCase(const U&); |
+ template <typename U> void appendSlowCase(U&&); |
using Base::m_size; |
using Base::buffer; |
@@ -978,7 +983,7 @@ void Vector<T, inlineCapacity, Allocator>::expandCapacity(size_t newMinCapacity) |
} |
template <typename T, size_t inlineCapacity, typename Allocator> |
-const T* Vector<T, inlineCapacity, Allocator>::expandCapacity(size_t newMinCapacity, const T* ptr) |
+T* Vector<T, inlineCapacity, Allocator>::expandCapacity(size_t newMinCapacity, T* ptr) |
{ |
if (ptr < begin() || ptr >= end()) { |
expandCapacity(newMinCapacity); |
@@ -1139,31 +1144,31 @@ void Vector<T, inlineCapacity, Allocator>::append(const U* data, size_t dataSize |
template <typename T, size_t inlineCapacity, typename Allocator> |
template <typename U> |
-ALWAYS_INLINE void Vector<T, inlineCapacity, Allocator>::append(const U& val) |
+ALWAYS_INLINE void Vector<T, inlineCapacity, Allocator>::append(U&& val) |
{ |
ASSERT(Allocator::isAllocationAllowed()); |
if (LIKELY(size() != capacity())) { |
ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size + 1); |
- new (NotNull, end()) T(val); |
+ new (NotNull, end()) T(std::forward<U>(val)); |
++m_size; |
return; |
} |
- appendSlowCase(val); |
+ appendSlowCase(std::forward<U>(val)); |
} |
template <typename T, size_t inlineCapacity, typename Allocator> |
template <typename U> |
-NEVER_INLINE void Vector<T, inlineCapacity, Allocator>::appendSlowCase(const U& val) |
+NEVER_INLINE void Vector<T, inlineCapacity, Allocator>::appendSlowCase(U&& val) |
{ |
ASSERT(size() == capacity()); |
- const U* ptr = &val; |
+ typename std::remove_reference<U>::type* ptr = &val; |
ptr = expandCapacity(size() + 1, ptr); |
ASSERT(begin()); |
ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size + 1); |
- new (NotNull, end()) T(*ptr); |
+ new (NotNull, end()) T(std::forward<U>(*ptr)); |
++m_size; |
} |
@@ -1172,16 +1177,15 @@ NEVER_INLINE void Vector<T, inlineCapacity, Allocator>::appendSlowCase(const U& |
template <typename T, size_t inlineCapacity, typename Allocator> |
template <typename U> |
-ALWAYS_INLINE void Vector<T, inlineCapacity, Allocator>::uncheckedAppend(const U& val) |
+ALWAYS_INLINE void Vector<T, inlineCapacity, Allocator>::uncheckedAppend(U&& val) |
{ |
#ifdef ANNOTATE_CONTIGUOUS_CONTAINER |
// Vectors in ASAN builds don't have inlineCapacity. |
- append(val); |
+ append(std::forward<U>(val)); |
#else |
ASSERT(size() < capacity()); |
ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size + 1); |
- const U* ptr = &val; |
- new (NotNull, end()) T(*ptr); |
+ new (NotNull, end()) T(std::forward<U>(val)); |
++m_size; |
#endif |
} |
@@ -1214,11 +1218,11 @@ void Vector<T, inlineCapacity, Allocator>::insert(size_t position, const U* data |
template <typename T, size_t inlineCapacity, typename Allocator> |
template <typename U> |
-inline void Vector<T, inlineCapacity, Allocator>::insert(size_t position, const U& val) |
+inline void Vector<T, inlineCapacity, Allocator>::insert(size_t position, U&& val) |
{ |
ASSERT(Allocator::isAllocationAllowed()); |
RELEASE_ASSERT(position <= size()); |
- const U* data = &val; |
+ typename std::remove_reference<U>::type* data = &val; |
if (size() == capacity()) { |
data = expandCapacity(size() + 1, data); |
ASSERT(begin()); |
@@ -1226,7 +1230,7 @@ inline void Vector<T, inlineCapacity, Allocator>::insert(size_t position, const |
ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size + 1); |
T* spot = begin() + position; |
TypeOperations::moveOverlapping(spot, end(), spot + 1); |
- new (NotNull, spot) T(*data); |
+ new (NotNull, spot) T(std::forward<U>(*data)); |
++m_size; |
} |
@@ -1246,9 +1250,9 @@ void Vector<T, inlineCapacity, Allocator>::prepend(const U* data, size_t dataSiz |
template <typename T, size_t inlineCapacity, typename Allocator> |
template <typename U> |
-inline void Vector<T, inlineCapacity, Allocator>::prepend(const U& val) |
+inline void Vector<T, inlineCapacity, Allocator>::prepend(U&& val) |
{ |
- insert(0, val); |
+ insert(0, std::forward<U>(val)); |
} |
template <typename T, size_t inlineCapacity, typename Allocator> |