| 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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 shrinkCapacity(size() + size() / 4 + 1); | 939 shrinkCapacity(size() + size() / 4 + 1); |
| 940 } | 940 } |
| 941 | 941 |
| 942 void clear() { shrinkCapacity(0); } | 942 void clear() { shrinkCapacity(0); } |
| 943 | 943 |
| 944 template <typename U> | 944 template <typename U> |
| 945 void append(const U*, size_t); | 945 void append(const U*, size_t); |
| 946 template <typename U> | 946 template <typename U> |
| 947 void append(U&&); | 947 void append(U&&); |
| 948 template <typename... Args> | 948 template <typename... Args> |
| 949 void emplaceAppend(Args&&...); | 949 T& emplace_back(Args&&...); |
| 950 template <typename U> | 950 template <typename U> |
| 951 void uncheckedAppend(U&& val); | 951 void uncheckedAppend(U&& val); |
| 952 template <typename U, size_t otherCapacity, typename V> | 952 template <typename U, size_t otherCapacity, typename V> |
| 953 void appendVector(const Vector<U, otherCapacity, V>&); | 953 void appendVector(const Vector<U, otherCapacity, V>&); |
| 954 | 954 |
| 955 template <typename U> | 955 template <typename U> |
| 956 void insert(size_t position, const U*, size_t); | 956 void insert(size_t position, const U*, size_t); |
| 957 template <typename U> | 957 template <typename U> |
| 958 void insert(size_t position, U&&); | 958 void insert(size_t position, U&&); |
| 959 template <typename U, size_t c, typename V> | 959 template <typename U, size_t c, typename V> |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1389 new (NotNull, end()) T(std::forward<U>(val)); | 1389 new (NotNull, end()) T(std::forward<U>(val)); |
| 1390 ++m_size; | 1390 ++m_size; |
| 1391 return; | 1391 return; |
| 1392 } | 1392 } |
| 1393 | 1393 |
| 1394 appendSlowCase(std::forward<U>(val)); | 1394 appendSlowCase(std::forward<U>(val)); |
| 1395 } | 1395 } |
| 1396 | 1396 |
| 1397 template <typename T, size_t inlineCapacity, typename Allocator> | 1397 template <typename T, size_t inlineCapacity, typename Allocator> |
| 1398 template <typename... Args> | 1398 template <typename... Args> |
| 1399 ALWAYS_INLINE void Vector<T, inlineCapacity, Allocator>::emplaceAppend( | 1399 ALWAYS_INLINE T& Vector<T, inlineCapacity, Allocator>::emplace_back( |
| 1400 Args&&... args) { | 1400 Args&&... args) { |
| 1401 static_assert(sizeof...(Args), "grow() must be called instead"); | 1401 static_assert(sizeof...(Args), "grow() must be called instead"); |
| 1402 static_assert(sizeof...(Args) != 1, "append() must be called instead"); | 1402 static_assert(sizeof...(Args) != 1, "append() must be called instead"); |
| 1403 | 1403 |
| 1404 DCHECK(Allocator::isAllocationAllowed()); | 1404 DCHECK(Allocator::isAllocationAllowed()); |
| 1405 if (UNLIKELY(size() == capacity())) | 1405 if (UNLIKELY(size() == capacity())) |
| 1406 expandCapacity(size() + 1); | 1406 expandCapacity(size() + 1); |
| 1407 | 1407 |
| 1408 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size + 1); | 1408 ANNOTATE_CHANGE_SIZE(begin(), capacity(), m_size, m_size + 1); |
| 1409 new (NotNull, end()) T(std::forward<Args>(args)...); | 1409 T* t = new (NotNull, end()) T(std::forward<Args>(args)...); |
| 1410 ++m_size; | 1410 ++m_size; |
| 1411 return *t; |
| 1411 } | 1412 } |
| 1412 | 1413 |
| 1413 template <typename T, size_t inlineCapacity, typename Allocator> | 1414 template <typename T, size_t inlineCapacity, typename Allocator> |
| 1414 template <typename U> | 1415 template <typename U> |
| 1415 NEVER_INLINE void Vector<T, inlineCapacity, Allocator>::appendSlowCase( | 1416 NEVER_INLINE void Vector<T, inlineCapacity, Allocator>::appendSlowCase( |
| 1416 U&& val) { | 1417 U&& val) { |
| 1417 ASSERT(size() == capacity()); | 1418 ASSERT(size() == capacity()); |
| 1418 | 1419 |
| 1419 typename std::remove_reference<U>::type* ptr = &val; | 1420 typename std::remove_reference<U>::type* ptr = &val; |
| 1420 ptr = expandCapacity(size() + 1, ptr); | 1421 ptr = expandCapacity(size() + 1, ptr); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 visitor, *const_cast<T*>(bufferEntry)); | 1605 visitor, *const_cast<T*>(bufferEntry)); |
| 1605 checkUnusedSlots(buffer() + size(), buffer() + capacity()); | 1606 checkUnusedSlots(buffer() + size(), buffer() + capacity()); |
| 1606 } | 1607 } |
| 1607 } | 1608 } |
| 1608 | 1609 |
| 1609 } // namespace WTF | 1610 } // namespace WTF |
| 1610 | 1611 |
| 1611 using WTF::Vector; | 1612 using WTF::Vector; |
| 1612 | 1613 |
| 1613 #endif // WTF_Vector_h | 1614 #endif // WTF_Vector_h |
| OLD | NEW |