| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 template<typename T> | 73 template<typename T> |
| 74 struct VectorUnusedSlotClearer<true, T> { | 74 struct VectorUnusedSlotClearer<true, T> { |
| 75 static void clear(T* begin, T* end) | 75 static void clear(T* begin, T* end) |
| 76 { | 76 { |
| 77 // We clear out unused slots so that the visitor and the finalizer | 77 // We clear out unused slots so that the visitor and the finalizer |
| 78 // do not visit them (or at least it does not matter if they do). | 78 // do not visit them (or at least it does not matter if they do). |
| 79 memset(begin, 0, sizeof(T) * (end - begin)); | 79 memset(begin, 0, sizeof(T) * (end - begin)); |
| 80 } | 80 } |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 template <bool needsInitialization, bool canInitializeWithMemset, typename T
> | 83 template <bool canInitializeWithMemset, typename T> |
| 84 struct VectorInitializer; | 84 struct VectorInitializer; |
| 85 | 85 |
| 86 template<bool ignore, typename T> | |
| 87 struct VectorInitializer<false, ignore, T> | |
| 88 { | |
| 89 static void initialize(T*, T*) {} | |
| 90 }; | |
| 91 | |
| 92 template<typename T> | 86 template<typename T> |
| 93 struct VectorInitializer<true, false, T> | 87 struct VectorInitializer<false, T> |
| 94 { | 88 { |
| 95 static void initialize(T* begin, T* end) | 89 static void initialize(T* begin, T* end) |
| 96 { | 90 { |
| 97 for (T* cur = begin; cur != end; ++cur) | 91 for (T* cur = begin; cur != end; ++cur) |
| 98 new (NotNull, cur) T; | 92 new (NotNull, cur) T; |
| 99 } | 93 } |
| 100 }; | 94 }; |
| 101 | 95 |
| 102 template<typename T> | 96 template<typename T> |
| 103 struct VectorInitializer<true, true, T> | 97 struct VectorInitializer<true, T> |
| 104 { | 98 { |
| 105 static void initialize(T* begin, T* end) | 99 static void initialize(T* begin, T* end) |
| 106 { | 100 { |
| 107 memset(begin, 0, reinterpret_cast<char*>(end) - reinterpret_cast<cha
r*>(begin)); | 101 memset(begin, 0, reinterpret_cast<char*>(end) - reinterpret_cast<cha
r*>(begin)); |
| 108 } | 102 } |
| 109 }; | 103 }; |
| 110 | 104 |
| 111 template <bool canMoveWithMemcpy, typename T> | 105 template <bool canMoveWithMemcpy, typename T> |
| 112 struct VectorMover; | 106 struct VectorMover; |
| 113 | 107 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 template<typename T> | 237 template<typename T> |
| 244 struct VectorTypeOperations | 238 struct VectorTypeOperations |
| 245 { | 239 { |
| 246 static void destruct(T* begin, T* end) | 240 static void destruct(T* begin, T* end) |
| 247 { | 241 { |
| 248 VectorDestructor<VectorTraits<T>::needsDestruction, T>::destruct(beg
in, end); | 242 VectorDestructor<VectorTraits<T>::needsDestruction, T>::destruct(beg
in, end); |
| 249 } | 243 } |
| 250 | 244 |
| 251 static void initialize(T* begin, T* end) | 245 static void initialize(T* begin, T* end) |
| 252 { | 246 { |
| 253 VectorInitializer<VectorTraits<T>::needsInitialization, VectorTraits
<T>::canInitializeWithMemset, T>::initialize(begin, end); | 247 VectorInitializer<VectorTraits<T>::canInitializeWithMemset, T>::init
ialize(begin, end); |
| 254 } | 248 } |
| 255 | 249 |
| 256 static void move(const T* src, const T* srcEnd, T* dst) | 250 static void move(const T* src, const T* srcEnd, T* dst) |
| 257 { | 251 { |
| 258 VectorMover<VectorTraits<T>::canMoveWithMemcpy, T>::move(src, srcEnd
, dst); | 252 VectorMover<VectorTraits<T>::canMoveWithMemcpy, T>::move(src, srcEnd
, dst); |
| 259 } | 253 } |
| 260 | 254 |
| 261 static void moveOverlapping(const T* src, const T* srcEnd, T* dst) | 255 static void moveOverlapping(const T* src, const T* srcEnd, T* dst) |
| 262 { | 256 { |
| 263 VectorMover<VectorTraits<T>::canMoveWithMemcpy, T>::moveOverlapping(
src, srcEnd, dst); | 257 VectorMover<VectorTraits<T>::canMoveWithMemcpy, T>::moveOverlapping(
src, srcEnd, dst); |
| (...skipping 930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 } | 1188 } |
| 1195 if (this->hasOutOfLineBuffer()) | 1189 if (this->hasOutOfLineBuffer()) |
| 1196 Allocator::markNoTracing(visitor, buffer()); | 1190 Allocator::markNoTracing(visitor, buffer()); |
| 1197 } | 1191 } |
| 1198 | 1192 |
| 1199 } // namespace WTF | 1193 } // namespace WTF |
| 1200 | 1194 |
| 1201 using WTF::Vector; | 1195 using WTF::Vector; |
| 1202 | 1196 |
| 1203 #endif // WTF_Vector_h | 1197 #endif // WTF_Vector_h |
| OLD | NEW |