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 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 ASSERT(size >= m_size); | 828 ASSERT(size >= m_size); |
829 if (size > capacity()) | 829 if (size > capacity()) |
830 expandCapacity(size); | 830 expandCapacity(size); |
831 TypeOperations::initialize(end(), begin() + size); | 831 TypeOperations::initialize(end(), begin() + size); |
832 m_size = size; | 832 m_size = size; |
833 } | 833 } |
834 | 834 |
835 template<typename T, size_t inlineCapacity> | 835 template<typename T, size_t inlineCapacity> |
836 void Vector<T, inlineCapacity>::reserveCapacity(size_t newCapacity) | 836 void Vector<T, inlineCapacity>::reserveCapacity(size_t newCapacity) |
837 { | 837 { |
838 if (newCapacity <= capacity()) | 838 if (UNLIKELY(newCapacity <= capacity())) |
839 return; | 839 return; |
840 T* oldBuffer = begin(); | 840 T* oldBuffer = begin(); |
841 T* oldEnd = end(); | 841 T* oldEnd = end(); |
842 Base::allocateBuffer(newCapacity); | 842 Base::allocateBuffer(newCapacity); |
843 if (begin()) | 843 TypeOperations::move(oldBuffer, oldEnd, begin()); |
844 TypeOperations::move(oldBuffer, oldEnd, begin()); | |
845 Base::deallocateBuffer(oldBuffer); | 844 Base::deallocateBuffer(oldBuffer); |
846 } | 845 } |
847 | 846 |
848 template<typename T, size_t inlineCapacity> | 847 template<typename T, size_t inlineCapacity> |
849 inline void Vector<T, inlineCapacity>::reserveInitialCapacity(size_t initial
Capacity) | 848 inline void Vector<T, inlineCapacity>::reserveInitialCapacity(size_t initial
Capacity) |
850 { | 849 { |
851 ASSERT(!m_size); | 850 ASSERT(!m_size); |
852 ASSERT(capacity() == inlineCapacity); | 851 ASSERT(capacity() == inlineCapacity); |
853 if (initialCapacity > inlineCapacity) | 852 if (initialCapacity > inlineCapacity) |
854 Base::allocateBuffer(initialCapacity); | 853 Base::allocateBuffer(initialCapacity); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 inline bool operator!=(const Vector<T, inlineCapacity>& a, const Vector<T, i
nlineCapacity>& b) | 1063 inline bool operator!=(const Vector<T, inlineCapacity>& a, const Vector<T, i
nlineCapacity>& b) |
1065 { | 1064 { |
1066 return !(a == b); | 1065 return !(a == b); |
1067 } | 1066 } |
1068 | 1067 |
1069 } // namespace WTF | 1068 } // namespace WTF |
1070 | 1069 |
1071 using WTF::Vector; | 1070 using WTF::Vector; |
1072 | 1071 |
1073 #endif // WTF_Vector_h | 1072 #endif // WTF_Vector_h |
OLD | NEW |