OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } else { | 144 } else { |
145 T* dstEnd = dst + (srcEnd - src); | 145 T* dstEnd = dst + (srcEnd - src); |
146 while (src != srcEnd) { | 146 while (src != srcEnd) { |
147 --srcEnd; | 147 --srcEnd; |
148 --dstEnd; | 148 --dstEnd; |
149 new (NotNull, dstEnd) T(*srcEnd); | 149 new (NotNull, dstEnd) T(*srcEnd); |
150 srcEnd->~T(); | 150 srcEnd->~T(); |
151 } | 151 } |
152 } | 152 } |
153 } | 153 } |
154 static void swap(T* src, T* srcEnd, T* dst) | 154 static void swap(T* src, T* srcEnd, T* dst) |
155 { | 155 { |
156 std::swap_ranges(src, srcEnd, dst); | 156 std::swap_ranges(src, srcEnd, dst); |
157 } | 157 } |
158 }; | 158 }; |
159 | 159 |
160 template <typename T> | 160 template <typename T> |
161 struct VectorMover<true, T> { | 161 struct VectorMover<true, T> { |
162 static void move(const T* src, const T* srcEnd, T* dst) | 162 static void move(const T* src, const T* srcEnd, T* dst) |
163 { | 163 { |
164 if (LIKELY(dst && src)) | 164 if (LIKELY(dst && src)) |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 280 |
281 static void swap(T* src, T* srcEnd, T* dst) | 281 static void swap(T* src, T* srcEnd, T* dst) |
282 { | 282 { |
283 VectorMover<VectorTraits<T>::canMoveWithMemcpy, T>::swap(src, srcEnd, ds
t); | 283 VectorMover<VectorTraits<T>::canMoveWithMemcpy, T>::swap(src, srcEnd, ds
t); |
284 } | 284 } |
285 | 285 |
286 static void uninitializedCopy(const T* src, const T* srcEnd, T* dst) | 286 static void uninitializedCopy(const T* src, const T* srcEnd, T* dst) |
287 { | 287 { |
288 VectorCopier<VectorTraits<T>::canCopyWithMemcpy, T>::uninitializedCopy(s
rc, srcEnd, dst); | 288 VectorCopier<VectorTraits<T>::canCopyWithMemcpy, T>::uninitializedCopy(s
rc, srcEnd, dst); |
289 } | 289 } |
290 | 290 |
291 static void uninitializedFill(T* dst, T* dstEnd, const T& val) | 291 static void uninitializedFill(T* dst, T* dstEnd, const T& val) |
292 { | 292 { |
293 VectorFiller<VectorTraits<T>::canFillWithMemset, T>::uninitializedFill(d
st, dstEnd, val); | 293 VectorFiller<VectorTraits<T>::canFillWithMemset, T>::uninitializedFill(d
st, dstEnd, val); |
294 } | 294 } |
295 | 295 |
296 static bool compare(const T* a, const T* b, size_t size) | 296 static bool compare(const T* a, const T* b, size_t size) |
297 { | 297 { |
298 return VectorComparer<VectorTraits<T>::canCompareWithMemcmp, T>::compare
(a, b, size); | 298 return VectorComparer<VectorTraits<T>::canCompareWithMemcmp, T>::compare
(a, b, size); |
299 } | 299 } |
300 }; | 300 }; |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 void swap(Vector& other) | 779 void swap(Vector& other) |
780 { | 780 { |
781 Base::swapVectorBuffer(other); | 781 Base::swapVectorBuffer(other); |
782 std::swap(m_size, other.m_size); | 782 std::swap(m_size, other.m_size); |
783 } | 783 } |
784 | 784 |
785 void reverse(); | 785 void reverse(); |
786 | 786 |
787 template <typename VisitorDispatcher> void trace(VisitorDispatcher); | 787 template <typename VisitorDispatcher> void trace(VisitorDispatcher); |
788 | 788 |
| 789 protected: |
| 790 using Base::checkUnusedSlots; |
| 791 using Base::clearUnusedSlots; |
| 792 |
789 private: | 793 private: |
790 void expandCapacity(size_t newMinCapacity); | 794 void expandCapacity(size_t newMinCapacity); |
791 const T* expandCapacity(size_t newMinCapacity, const T*); | 795 const T* expandCapacity(size_t newMinCapacity, const T*); |
792 template <typename U> U* expandCapacity(size_t newMinCapacity, U*); | 796 template <typename U> U* expandCapacity(size_t newMinCapacity, U*); |
793 void shrinkCapacity(size_t newCapacity); | 797 void shrinkCapacity(size_t newCapacity); |
794 template <typename U> void appendSlowCase(const U&); | 798 template <typename U> void appendSlowCase(const U&); |
795 | 799 |
796 using Base::m_size; | 800 using Base::m_size; |
797 using Base::buffer; | 801 using Base::buffer; |
798 using Base::capacity; | 802 using Base::capacity; |
799 using Base::swapVectorBuffer; | 803 using Base::swapVectorBuffer; |
800 using Base::allocateBuffer; | 804 using Base::allocateBuffer; |
801 using Base::allocationSize; | 805 using Base::allocationSize; |
802 using Base::clearUnusedSlots; | |
803 using Base::checkUnusedSlots; | |
804 }; | 806 }; |
805 | 807 |
806 template <typename T, size_t inlineCapacity, typename Allocator> | 808 template <typename T, size_t inlineCapacity, typename Allocator> |
807 Vector<T, inlineCapacity, Allocator>::Vector(const Vector& other) | 809 Vector<T, inlineCapacity, Allocator>::Vector(const Vector& other) |
808 : Base(other.capacity()) | 810 : Base(other.capacity()) |
809 { | 811 { |
810 ANNOTATE_NEW_BUFFER(begin(), capacity(), other.size()); | 812 ANNOTATE_NEW_BUFFER(begin(), capacity(), other.size()); |
811 m_size = other.size(); | 813 m_size = other.size(); |
812 TypeOperations::uninitializedCopy(other.begin(), other.end(), begin()); | 814 TypeOperations::uninitializedCopy(other.begin(), other.end(), begin()); |
813 } | 815 } |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1342 struct NeedsTracing<Vector<T, N>> { | 1344 struct NeedsTracing<Vector<T, N>> { |
1343 static const bool value = false; | 1345 static const bool value = false; |
1344 }; | 1346 }; |
1345 #endif | 1347 #endif |
1346 | 1348 |
1347 } // namespace WTF | 1349 } // namespace WTF |
1348 | 1350 |
1349 using WTF::Vector; | 1351 using WTF::Vector; |
1350 | 1352 |
1351 #endif // WTF_Vector_h | 1353 #endif // WTF_Vector_h |
OLD | NEW |