| 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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 void shrinkToReasonableCapacity() | 910 void shrinkToReasonableCapacity() |
| 911 { | 911 { |
| 912 if (size() * 2 < capacity()) | 912 if (size() * 2 < capacity()) |
| 913 shrinkCapacity(size() + size() / 4 + 1); | 913 shrinkCapacity(size() + size() / 4 + 1); |
| 914 } | 914 } |
| 915 | 915 |
| 916 void clear() { shrinkCapacity(0); } | 916 void clear() { shrinkCapacity(0); } |
| 917 | 917 |
| 918 template <typename U> void append(const U*, size_t); | 918 template <typename U> void append(const U*, size_t); |
| 919 template <typename U> void append(U&&); | 919 template <typename U> void append(U&&); |
| 920 template <typename... Args> void emplaceAppend(Args&&...); |
| 920 template <typename U> void uncheckedAppend(U&& val); | 921 template <typename U> void uncheckedAppend(U&& val); |
| 921 template <typename U, size_t otherCapacity, typename V> void appendVector(co
nst Vector<U, otherCapacity, V>&); | 922 template <typename U, size_t otherCapacity, typename V> void appendVector(co
nst Vector<U, otherCapacity, V>&); |
| 922 | 923 |
| 923 template <typename U> void insert(size_t position, const U*, size_t); | 924 template <typename U> void insert(size_t position, const U*, size_t); |
| 924 template <typename U> void insert(size_t position, U&&); | 925 template <typename U> void insert(size_t position, U&&); |
| 925 template <typename U, size_t c, typename V> void insert(size_t position, con
st Vector<U, c, V>&); | 926 template <typename U, size_t c, typename V> void insert(size_t position, con
st Vector<U, c, V>&); |
| 926 | 927 |
| 927 template <typename U> void prepend(const U*, size_t); | 928 template <typename U> void prepend(const U*, size_t); |
| 928 template <typename U> void prepend(U&&); | 929 template <typename U> void prepend(U&&); |
| 929 template <typename U, size_t c, typename V> void prependVector(const Vector<
U, c, V>&); | 930 template <typename U, size_t c, typename V> void prependVector(const Vector<
U, c, V>&); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 if (LIKELY(size() != capacity())) { | 1361 if (LIKELY(size() != capacity())) { |
| 1361 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size + 1); | 1362 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size + 1); |
| 1362 new (NotNull, end()) T(std::forward<U>(val)); | 1363 new (NotNull, end()) T(std::forward<U>(val)); |
| 1363 ++m_size; | 1364 ++m_size; |
| 1364 return; | 1365 return; |
| 1365 } | 1366 } |
| 1366 | 1367 |
| 1367 appendSlowCase(std::forward<U>(val)); | 1368 appendSlowCase(std::forward<U>(val)); |
| 1368 } | 1369 } |
| 1369 | 1370 |
| 1371 |
| 1372 template <typename T, size_t inlineCapacity, typename Allocator> |
| 1373 template <typename... Args> |
| 1374 ALWAYS_INLINE void Vector<T, inlineCapacity, Allocator>::emplaceAppend(Args&&...
args) |
| 1375 { |
| 1376 static_assert(sizeof...(Args), "grow() must be called instead"); |
| 1377 static_assert(sizeof...(Args) != 1, "append() must be called instead"); |
| 1378 |
| 1379 DCHECK(Allocator::isAllocationAllowed()); |
| 1380 if (UNLIKELY(size() == capacity())) |
| 1381 expandCapacity(size() + 1); |
| 1382 |
| 1383 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size + 1); |
| 1384 new (NotNull, end()) T(std::forward<Args>(args)...); |
| 1385 ++m_size; |
| 1386 } |
| 1387 |
| 1370 template <typename T, size_t inlineCapacity, typename Allocator> | 1388 template <typename T, size_t inlineCapacity, typename Allocator> |
| 1371 template <typename U> | 1389 template <typename U> |
| 1372 NEVER_INLINE void Vector<T, inlineCapacity, Allocator>::appendSlowCase(U&& val) | 1390 NEVER_INLINE void Vector<T, inlineCapacity, Allocator>::appendSlowCase(U&& val) |
| 1373 { | 1391 { |
| 1374 ASSERT(size() == capacity()); | 1392 ASSERT(size() == capacity()); |
| 1375 | 1393 |
| 1376 typename std::remove_reference<U>::type* ptr = &val; | 1394 typename std::remove_reference<U>::type* ptr = &val; |
| 1377 ptr = expandCapacity(size() + 1, ptr); | 1395 ptr = expandCapacity(size() + 1, ptr); |
| 1378 ASSERT(begin()); | 1396 ASSERT(begin()); |
| 1379 | 1397 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>(vis
itor, *const_cast<T*>(bufferEntry)); | 1572 Allocator::template trace<VisitorDispatcher, T, VectorTraits<T>>(vis
itor, *const_cast<T*>(bufferEntry)); |
| 1555 checkUnusedSlots(buffer() + size(), buffer() + capacity()); | 1573 checkUnusedSlots(buffer() + size(), buffer() + capacity()); |
| 1556 } | 1574 } |
| 1557 } | 1575 } |
| 1558 | 1576 |
| 1559 } // namespace WTF | 1577 } // namespace WTF |
| 1560 | 1578 |
| 1561 using WTF::Vector; | 1579 using WTF::Vector; |
| 1562 | 1580 |
| 1563 #endif // WTF_Vector_h | 1581 #endif // WTF_Vector_h |
| OLD | NEW |