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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 static void swap(T* src, T* srcEnd, T* dst) { | 166 static void swap(T* src, T* srcEnd, T* dst) { |
167 std::swap_ranges(src, srcEnd, dst); | 167 std::swap_ranges(src, srcEnd, dst); |
168 } | 168 } |
169 }; | 169 }; |
170 | 170 |
171 template <typename T> | 171 template <typename T> |
172 struct VectorMover<true, T> { | 172 struct VectorMover<true, T> { |
173 STATIC_ONLY(VectorMover); | 173 STATIC_ONLY(VectorMover); |
174 static void move(const T* src, const T* srcEnd, T* dst) { | 174 static void move(const T* src, const T* srcEnd, T* dst) { |
175 if (LIKELY(dst && src)) | 175 if (LIKELY(dst && src)) |
176 memcpy(dst, src, reinterpret_cast<const char*>(srcEnd) - | 176 memcpy(dst, src, |
177 reinterpret_cast<const char*>(src)); | 177 reinterpret_cast<const char*>(srcEnd) - |
| 178 reinterpret_cast<const char*>(src)); |
178 } | 179 } |
179 static void moveOverlapping(const T* src, const T* srcEnd, T* dst) { | 180 static void moveOverlapping(const T* src, const T* srcEnd, T* dst) { |
180 if (LIKELY(dst && src)) | 181 if (LIKELY(dst && src)) |
181 memmove(dst, src, reinterpret_cast<const char*>(srcEnd) - | 182 memmove(dst, src, |
182 reinterpret_cast<const char*>(src)); | 183 reinterpret_cast<const char*>(srcEnd) - |
| 184 reinterpret_cast<const char*>(src)); |
183 } | 185 } |
184 static void swap(T* src, T* srcEnd, T* dst) { | 186 static void swap(T* src, T* srcEnd, T* dst) { |
185 std::swap_ranges(reinterpret_cast<char*>(src), | 187 std::swap_ranges(reinterpret_cast<char*>(src), |
186 reinterpret_cast<char*>(srcEnd), | 188 reinterpret_cast<char*>(srcEnd), |
187 reinterpret_cast<char*>(dst)); | 189 reinterpret_cast<char*>(dst)); |
188 } | 190 } |
189 }; | 191 }; |
190 | 192 |
191 template <bool canCopyWithMemcpy, typename T> | 193 template <bool canCopyWithMemcpy, typename T> |
192 struct VectorCopier; | 194 struct VectorCopier; |
193 | 195 |
194 template <typename T> | 196 template <typename T> |
195 struct VectorCopier<false, T> { | 197 struct VectorCopier<false, T> { |
196 STATIC_ONLY(VectorCopier); | 198 STATIC_ONLY(VectorCopier); |
197 template <typename U> | 199 template <typename U> |
198 static void uninitializedCopy(const U* src, const U* srcEnd, T* dst) { | 200 static void uninitializedCopy(const U* src, const U* srcEnd, T* dst) { |
199 while (src != srcEnd) { | 201 while (src != srcEnd) { |
200 new (NotNull, dst) T(*src); | 202 new (NotNull, dst) T(*src); |
201 ++dst; | 203 ++dst; |
202 ++src; | 204 ++src; |
203 } | 205 } |
204 } | 206 } |
205 }; | 207 }; |
206 | 208 |
207 template <typename T> | 209 template <typename T> |
208 struct VectorCopier<true, T> { | 210 struct VectorCopier<true, T> { |
209 STATIC_ONLY(VectorCopier); | 211 STATIC_ONLY(VectorCopier); |
210 static void uninitializedCopy(const T* src, const T* srcEnd, T* dst) { | 212 static void uninitializedCopy(const T* src, const T* srcEnd, T* dst) { |
211 if (LIKELY(dst && src)) | 213 if (LIKELY(dst && src)) |
212 memcpy(dst, src, reinterpret_cast<const char*>(srcEnd) - | 214 memcpy(dst, src, |
213 reinterpret_cast<const char*>(src)); | 215 reinterpret_cast<const char*>(srcEnd) - |
| 216 reinterpret_cast<const char*>(src)); |
214 } | 217 } |
215 template <typename U> | 218 template <typename U> |
216 static void uninitializedCopy(const U* src, const U* srcEnd, T* dst) { | 219 static void uninitializedCopy(const U* src, const U* srcEnd, T* dst) { |
217 VectorCopier<false, T>::uninitializedCopy(src, srcEnd, dst); | 220 VectorCopier<false, T>::uninitializedCopy(src, srcEnd, dst); |
218 } | 221 } |
219 }; | 222 }; |
220 | 223 |
221 template <bool canFillWithMemset, typename T> | 224 template <bool canFillWithMemset, typename T> |
222 struct VectorFiller; | 225 struct VectorFiller; |
223 | 226 |
(...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1793 visitor, *const_cast<T*>(bufferEntry)); | 1796 visitor, *const_cast<T*>(bufferEntry)); |
1794 checkUnusedSlots(buffer() + size(), buffer() + capacity()); | 1797 checkUnusedSlots(buffer() + size(), buffer() + capacity()); |
1795 } | 1798 } |
1796 } | 1799 } |
1797 | 1800 |
1798 } // namespace WTF | 1801 } // namespace WTF |
1799 | 1802 |
1800 using WTF::Vector; | 1803 using WTF::Vector; |
1801 | 1804 |
1802 #endif // WTF_Vector_h | 1805 #endif // WTF_Vector_h |
OLD | NEW |