| 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 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 "an off-heap Vector. Use HeapVector<Member<T>> instead."); | 1187 "an off-heap Vector. Use HeapVector<Member<T>> instead."); |
| 1188 | 1188 |
| 1189 ANNOTATE_NEW_BUFFER(begin(), capacity(), size); | 1189 ANNOTATE_NEW_BUFFER(begin(), capacity(), size); |
| 1190 m_size = size; | 1190 m_size = size; |
| 1191 TypeOperations::initialize(begin(), end()); | 1191 TypeOperations::initialize(begin(), end()); |
| 1192 } | 1192 } |
| 1193 | 1193 |
| 1194 template <typename T, size_t inlineCapacity, typename Allocator> | 1194 template <typename T, size_t inlineCapacity, typename Allocator> |
| 1195 inline Vector<T, inlineCapacity, Allocator>::Vector(size_t size, const T& val) | 1195 inline Vector<T, inlineCapacity, Allocator>::Vector(size_t size, const T& val) |
| 1196 : Base(size) { | 1196 : Base(size) { |
| 1197 // TODO(yutak): Introduce these assertions. Some use sites call this function | 1197 static_assert(!std::is_polymorphic<T>::value || |
| 1198 // in the context where T is an incomplete type. | 1198 !VectorTraits<T>::canInitializeWithMemset, |
| 1199 // | 1199 "Cannot initialize with memset if there is a vtable"); |
| 1200 // static_assert(!std::is_polymorphic<T>::value || | 1200 static_assert(Allocator::isGarbageCollected || |
| 1201 // !VectorTraits<T>::canInitializeWithMemset, | 1201 !AllowsOnlyPlacementNew<T>::value || |
| 1202 // "Cannot initialize with memset if there is a vtable"); | 1202 !IsTraceable<T>::value, |
| 1203 // static_assert(Allocator::isGarbageCollected || | 1203 "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_NEW objects that " |
| 1204 // !AllowsOnlyPlacementNew<T>::value || | 1204 "have trace methods into an off-heap Vector"); |
| 1205 // !IsTraceable<T>::value, | 1205 static_assert(Allocator::isGarbageCollected || |
| 1206 // "Cannot put DISALLOW_NEW_EXCEPT_PLACEMENT_NEW objects that " | 1206 !IsPointerToGarbageCollectedType<T>::value, |
| 1207 // "have trace methods into an off-heap Vector"); | 1207 "Cannot put raw pointers to garbage-collected classes into " |
| 1208 // static_assert(Allocator::isGarbageCollected || | 1208 "an off-heap Vector. Use HeapVector<Member<T>> instead."); |
| 1209 // !IsPointerToGarbageCollectedType<T>::value, | |
| 1210 // "Cannot put raw pointers to garbage-collected classes into " | |
| 1211 // "an off-heap Vector. Use HeapVector<Member<T>> instead."); | |
| 1212 | 1209 |
| 1213 ANNOTATE_NEW_BUFFER(begin(), capacity(), size); | 1210 ANNOTATE_NEW_BUFFER(begin(), capacity(), size); |
| 1214 m_size = size; | 1211 m_size = size; |
| 1215 TypeOperations::uninitializedFill(begin(), end(), val); | 1212 TypeOperations::uninitializedFill(begin(), end(), val); |
| 1216 } | 1213 } |
| 1217 | 1214 |
| 1218 template <typename T, size_t inlineCapacity, typename Allocator> | 1215 template <typename T, size_t inlineCapacity, typename Allocator> |
| 1219 Vector<T, inlineCapacity, Allocator>::Vector(const Vector& other) | 1216 Vector<T, inlineCapacity, Allocator>::Vector(const Vector& other) |
| 1220 : Base(other.capacity()) { | 1217 : Base(other.capacity()) { |
| 1221 ANNOTATE_NEW_BUFFER(begin(), capacity(), other.size()); | 1218 ANNOTATE_NEW_BUFFER(begin(), capacity(), other.size()); |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1793 visitor, *const_cast<T*>(bufferEntry)); | 1790 visitor, *const_cast<T*>(bufferEntry)); |
| 1794 checkUnusedSlots(buffer() + size(), buffer() + capacity()); | 1791 checkUnusedSlots(buffer() + size(), buffer() + capacity()); |
| 1795 } | 1792 } |
| 1796 } | 1793 } |
| 1797 | 1794 |
| 1798 } // namespace WTF | 1795 } // namespace WTF |
| 1799 | 1796 |
| 1800 using WTF::Vector; | 1797 using WTF::Vector; |
| 1801 | 1798 |
| 1802 #endif // WTF_Vector_h | 1799 #endif // WTF_Vector_h |
| OLD | NEW |