| Index: Source/wtf/Vector.h
|
| diff --git a/Source/wtf/Vector.h b/Source/wtf/Vector.h
|
| index c98c0b476899f4d9293d4ec47495f306ed29ba62..e62f79798592193255a22eaf055e1cc9bfc192c2 100644
|
| --- a/Source/wtf/Vector.h
|
| +++ b/Source/wtf/Vector.h
|
| @@ -46,7 +46,7 @@ namespace WTF {
|
| template<typename T>
|
| struct VectorDestructor<true, T>
|
| {
|
| - static void destruct(T* begin, T* end)
|
| + static void destruct(T* begin, T* end)
|
| {
|
| for (T* cur = begin; cur != end; ++cur)
|
| cur->~T();
|
| @@ -65,7 +65,7 @@ namespace WTF {
|
| template<typename T>
|
| struct VectorInitializer<true, false, T>
|
| {
|
| - static void initialize(T* begin, T* end)
|
| + static void initialize(T* begin, T* end)
|
| {
|
| for (T* cur = begin; cur != end; ++cur)
|
| new (NotNull, cur) T;
|
| @@ -75,7 +75,7 @@ namespace WTF {
|
| template<typename T>
|
| struct VectorInitializer<true, true, T>
|
| {
|
| - static void initialize(T* begin, T* end)
|
| + static void initialize(T* begin, T* end)
|
| {
|
| memset(begin, 0, reinterpret_cast<char*>(end) - reinterpret_cast<char*>(begin));
|
| }
|
| @@ -115,11 +115,11 @@ namespace WTF {
|
| template<typename T>
|
| struct VectorMover<true, T>
|
| {
|
| - static void move(const T* src, const T* srcEnd, T* dst)
|
| + static void move(const T* src, const T* srcEnd, T* dst)
|
| {
|
| memcpy(dst, src, reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
|
| }
|
| - static void moveOverlapping(const T* src, const T* srcEnd, T* dst)
|
| + static void moveOverlapping(const T* src, const T* srcEnd, T* dst)
|
| {
|
| memmove(dst, src, reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
|
| }
|
| @@ -131,7 +131,7 @@ namespace WTF {
|
| template<typename T>
|
| struct VectorCopier<false, T>
|
| {
|
| - static void uninitializedCopy(const T* src, const T* srcEnd, T* dst)
|
| + static void uninitializedCopy(const T* src, const T* srcEnd, T* dst)
|
| {
|
| while (src != srcEnd) {
|
| new (NotNull, dst) T(*src);
|
| @@ -144,7 +144,7 @@ namespace WTF {
|
| template<typename T>
|
| struct VectorCopier<true, T>
|
| {
|
| - static void uninitializedCopy(const T* src, const T* srcEnd, T* dst)
|
| + static void uninitializedCopy(const T* src, const T* srcEnd, T* dst)
|
| {
|
| memcpy(dst, src, reinterpret_cast<const char*>(srcEnd) - reinterpret_cast<const char*>(src));
|
| }
|
| @@ -156,7 +156,7 @@ namespace WTF {
|
| template<typename T>
|
| struct VectorFiller<false, T>
|
| {
|
| - static void uninitializedFill(T* dst, T* dstEnd, const T& val)
|
| + static void uninitializedFill(T* dst, T* dstEnd, const T& val)
|
| {
|
| while (dst != dstEnd) {
|
| new (NotNull, dst) T(val);
|
| @@ -168,7 +168,7 @@ namespace WTF {
|
| template<typename T>
|
| struct VectorFiller<true, T>
|
| {
|
| - static void uninitializedFill(T* dst, T* dstEnd, const T& val)
|
| + static void uninitializedFill(T* dst, T* dstEnd, const T& val)
|
| {
|
| ASSERT(sizeof(T) == sizeof(char));
|
| #if COMPILER(GCC) && defined(_FORTIFY_SOURCE)
|
| @@ -177,10 +177,10 @@ namespace WTF {
|
| memset(dst, val, dstEnd - dst);
|
| }
|
| };
|
| -
|
| +
|
| template<bool canCompareWithMemcmp, typename T>
|
| struct VectorComparer;
|
| -
|
| +
|
| template<typename T>
|
| struct VectorComparer<false, T>
|
| {
|
| @@ -201,7 +201,7 @@ namespace WTF {
|
| return memcmp(a, b, sizeof(T) * size) == 0;
|
| }
|
| };
|
| -
|
| +
|
| template<typename T>
|
| struct VectorTypeOperations
|
| {
|
| @@ -234,7 +234,7 @@ namespace WTF {
|
| {
|
| VectorFiller<VectorTraits<T>::canFillWithMemset, T>::uninitializedFill(dst, dstEnd, val);
|
| }
|
| -
|
| +
|
| static bool compare(const T* a, const T* b, size_t size)
|
| {
|
| return VectorComparer<VectorTraits<T>::canCompareWithMemcmp, T>::compare(a, b, size);
|
| @@ -291,7 +291,7 @@ namespace WTF {
|
| {
|
| if (!bufferToDeallocate)
|
| return;
|
| -
|
| +
|
| if (m_buffer == bufferToDeallocate) {
|
| m_buffer = 0;
|
| m_capacity = 0;
|
| @@ -358,13 +358,13 @@ namespace WTF {
|
| {
|
| deallocateBuffer(buffer());
|
| }
|
| -
|
| +
|
| void swap(VectorBuffer<T, 0>& other)
|
| {
|
| std::swap(m_buffer, other.m_buffer);
|
| std::swap(m_capacity, other.m_capacity);
|
| }
|
| -
|
| +
|
| void restoreInlineBufferIfNeeded() { }
|
|
|
| using Base::allocateBuffer;
|
| @@ -509,12 +509,12 @@ namespace WTF {
|
| typedef std::reverse_iterator<iterator> reverse_iterator;
|
| typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
|
|
| - Vector()
|
| + Vector()
|
| : m_size(0)
|
| {
|
| }
|
| -
|
| - explicit Vector(size_t size)
|
| +
|
| + explicit Vector(size_t size)
|
| : Base(size)
|
| , m_size(size)
|
| {
|
| @@ -529,11 +529,11 @@ namespace WTF {
|
| }
|
|
|
| Vector(const Vector&);
|
| - template<size_t otherCapacity>
|
| + template<size_t otherCapacity>
|
| Vector(const Vector<T, otherCapacity>&);
|
|
|
| Vector& operator=(const Vector&);
|
| - template<size_t otherCapacity>
|
| + template<size_t otherCapacity>
|
| Vector& operator=(const Vector<T, otherCapacity>&);
|
|
|
| #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
|
| @@ -545,12 +545,12 @@ namespace WTF {
|
| size_t capacity() const { return Base::capacity(); }
|
| bool isEmpty() const { return !size(); }
|
|
|
| - T& at(size_t i)
|
| - {
|
| + T& at(size_t i)
|
| + {
|
| RELEASE_ASSERT(i < size());
|
| return Base::buffer()[i];
|
| }
|
| - const T& at(size_t i) const
|
| + const T& at(size_t i) const
|
| {
|
| RELEASE_ASSERT(i < size());
|
| return Base::buffer()[i];
|
| @@ -610,10 +610,10 @@ namespace WTF {
|
| void remove(size_t position);
|
| void remove(size_t position, size_t length);
|
|
|
| - void removeLast()
|
| + void removeLast()
|
| {
|
| ASSERT(!isEmpty());
|
| - shrink(size() - 1);
|
| + shrink(size() - 1);
|
| }
|
|
|
| Vector(size_t size, const T& val)
|
| @@ -646,7 +646,7 @@ namespace WTF {
|
| const T* expandCapacity(size_t newMinCapacity, const T*);
|
| bool tryExpandCapacity(size_t newMinCapacity);
|
| const T* tryExpandCapacity(size_t newMinCapacity, const T*);
|
| - template<typename U> U* expandCapacity(size_t newMinCapacity, U*);
|
| + template<typename U> U* expandCapacity(size_t newMinCapacity, U*);
|
| template<typename U> void appendSlowCase(const U&);
|
|
|
| unsigned m_size;
|
| @@ -673,7 +673,7 @@ namespace WTF {
|
| }
|
|
|
| template<typename T, size_t inlineCapacity>
|
| - template<size_t otherCapacity>
|
| + template<size_t otherCapacity>
|
| Vector<T, inlineCapacity>::Vector(const Vector<T, otherCapacity>& other)
|
| : Base(other.capacity())
|
| , m_size(other.size())
|
| @@ -687,7 +687,7 @@ namespace WTF {
|
| {
|
| if (&other == this)
|
| return *this;
|
| -
|
| +
|
| if (size() > other.size())
|
| shrink(other.size());
|
| else if (other.size() > capacity()) {
|
| @@ -696,7 +696,7 @@ namespace WTF {
|
| if (!begin())
|
| return *this;
|
| }
|
| -
|
| +
|
| // Works around an assert in VS2010. See https://connect.microsoft.com/VisualStudio/feedback/details/558044/std-copy-should-not-check-dest-when-first-last
|
| #if COMPILER(MSVC) && defined(_ITERATOR_DEBUG_LEVEL) && _ITERATOR_DEBUG_LEVEL
|
| if (!begin())
|
| @@ -713,7 +713,7 @@ namespace WTF {
|
| inline bool typelessPointersAreEqual(const void* a, const void* b) { return a == b; }
|
|
|
| template<typename T, size_t inlineCapacity>
|
| - template<size_t otherCapacity>
|
| + template<size_t otherCapacity>
|
| Vector<T, inlineCapacity>& Vector<T, inlineCapacity>::operator=(const Vector<T, otherCapacity>& other)
|
| {
|
| // If the inline capacities match, we should call the more specific
|
| @@ -729,7 +729,7 @@ namespace WTF {
|
| if (!begin())
|
| return *this;
|
| }
|
| -
|
| +
|
| // Works around an assert in VS2010. See https://connect.microsoft.com/VisualStudio/feedback/details/558044/std-copy-should-not-check-dest-when-first-last
|
| #if COMPILER(MSVC) && defined(_ITERATOR_DEBUG_LEVEL) && _ITERATOR_DEBUG_LEVEL
|
| if (!begin())
|
| @@ -767,7 +767,7 @@ namespace WTF {
|
| {
|
| return find(value) != notFound;
|
| }
|
| -
|
| +
|
| template<typename T, size_t inlineCapacity>
|
| template<typename U>
|
| size_t Vector<T, inlineCapacity>::find(const U& value) const
|
| @@ -806,7 +806,7 @@ namespace WTF {
|
| if (!begin())
|
| return;
|
| }
|
| -
|
| +
|
| std::fill(begin(), end(), val);
|
| TypeOperations::uninitializedFill(end(), begin() + newSize, val);
|
| m_size = newSize;
|
| @@ -825,7 +825,7 @@ namespace WTF {
|
| {
|
| reserveCapacity(std::max(newMinCapacity, std::max(static_cast<size_t>(16), capacity() + capacity() / 4 + 1)));
|
| }
|
| -
|
| +
|
| template<typename T, size_t inlineCapacity>
|
| const T* Vector<T, inlineCapacity>::expandCapacity(size_t newMinCapacity, const T* ptr)
|
| {
|
| @@ -843,7 +843,7 @@ namespace WTF {
|
| {
|
| return tryReserveCapacity(std::max(newMinCapacity, std::max(static_cast<size_t>(16), capacity() + capacity() / 4 + 1)));
|
| }
|
| -
|
| +
|
| template<typename T, size_t inlineCapacity>
|
| const T* Vector<T, inlineCapacity>::tryExpandCapacity(size_t newMinCapacity, const T* ptr)
|
| {
|
| @@ -876,7 +876,7 @@ namespace WTF {
|
| if (begin())
|
| TypeOperations::initialize(end(), begin() + size);
|
| }
|
| -
|
| +
|
| m_size = size;
|
| }
|
|
|
| @@ -911,7 +911,7 @@ namespace WTF {
|
| TypeOperations::move(oldBuffer, oldEnd, begin());
|
| Base::deallocateBuffer(oldBuffer);
|
| }
|
| -
|
| +
|
| template<typename T, size_t inlineCapacity>
|
| bool Vector<T, inlineCapacity>::tryReserveCapacity(size_t newCapacity)
|
| {
|
| @@ -926,7 +926,7 @@ namespace WTF {
|
| Base::deallocateBuffer(oldBuffer);
|
| return true;
|
| }
|
| -
|
| +
|
| template<typename T, size_t inlineCapacity>
|
| inline void Vector<T, inlineCapacity>::reserveInitialCapacity(size_t initialCapacity)
|
| {
|
| @@ -935,14 +935,14 @@ namespace WTF {
|
| if (initialCapacity > inlineCapacity)
|
| Base::allocateBuffer(initialCapacity);
|
| }
|
| -
|
| +
|
| template<typename T, size_t inlineCapacity>
|
| void Vector<T, inlineCapacity>::shrinkCapacity(size_t newCapacity)
|
| {
|
| if (newCapacity >= capacity())
|
| return;
|
|
|
| - if (newCapacity < size())
|
| + if (newCapacity < size())
|
| shrink(newCapacity);
|
|
|
| T* oldBuffer = begin();
|
| @@ -1071,7 +1071,7 @@ namespace WTF {
|
| new (NotNull, &spot[i]) T(data[i]);
|
| m_size = newSize;
|
| }
|
| -
|
| +
|
| template<typename T, size_t inlineCapacity> template<typename U>
|
| inline void Vector<T, inlineCapacity>::insert(size_t position, const U& val)
|
| {
|
| @@ -1087,7 +1087,7 @@ namespace WTF {
|
| new (NotNull, spot) T(*data);
|
| ++m_size;
|
| }
|
| -
|
| +
|
| template<typename T, size_t inlineCapacity> template<typename U, size_t c>
|
| inline void Vector<T, inlineCapacity>::insert(size_t position, const Vector<U, c>& val)
|
| {
|
| @@ -1105,13 +1105,13 @@ namespace WTF {
|
| {
|
| insert(0, val);
|
| }
|
| -
|
| +
|
| template<typename T, size_t inlineCapacity> template<typename U, size_t c>
|
| inline void Vector<T, inlineCapacity>::prepend(const Vector<U, c>& val)
|
| {
|
| insert(0, val.begin(), val.size());
|
| }
|
| -
|
| +
|
| template<typename T, size_t inlineCapacity>
|
| inline void Vector<T, inlineCapacity>::remove(size_t position)
|
| {
|
| @@ -1129,7 +1129,7 @@ namespace WTF {
|
| RELEASE_ASSERT(position + length <= size());
|
| T* beginSpot = begin() + position;
|
| T* endSpot = beginSpot + length;
|
| - TypeOperations::destruct(beginSpot, endSpot);
|
| + TypeOperations::destruct(beginSpot, endSpot);
|
| TypeOperations::moveOverlapping(endSpot, end(), beginSpot);
|
| m_size -= length;
|
| }
|
|
|