| 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 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1619 } | 1619 } |
| 1620 | 1620 |
| 1621 template <typename T, size_t inlineCapacity, typename Allocator> | 1621 template <typename T, size_t inlineCapacity, typename Allocator> |
| 1622 void Vector<T, inlineCapacity, Allocator>::ShrinkCapacity(size_t new_capacity) { | 1622 void Vector<T, inlineCapacity, Allocator>::ShrinkCapacity(size_t new_capacity) { |
| 1623 if (new_capacity >= Capacity()) | 1623 if (new_capacity >= Capacity()) |
| 1624 return; | 1624 return; |
| 1625 | 1625 |
| 1626 if (new_capacity < size()) | 1626 if (new_capacity < size()) |
| 1627 Shrink(new_capacity); | 1627 Shrink(new_capacity); |
| 1628 | 1628 |
| 1629 if (Allocator::IsObjectResurrectionForbidden()) | |
| 1630 return; | |
| 1631 | |
| 1632 T* old_buffer = begin(); | 1629 T* old_buffer = begin(); |
| 1633 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER | 1630 #ifdef ANNOTATE_CONTIGUOUS_CONTAINER |
| 1634 size_t old_capacity = Capacity(); | 1631 size_t old_capacity = Capacity(); |
| 1635 #endif | 1632 #endif |
| 1636 if (new_capacity > 0) { | 1633 if (new_capacity > 0) { |
| 1637 if (Base::ShrinkBuffer(new_capacity)) { | 1634 if (Base::ShrinkBuffer(new_capacity)) { |
| 1638 ANNOTATE_CHANGE_CAPACITY(begin(), old_capacity, size_, Capacity()); | 1635 ANNOTATE_CHANGE_CAPACITY(begin(), old_capacity, size_, Capacity()); |
| 1639 return; | 1636 return; |
| 1640 } | 1637 } |
| 1641 | 1638 |
| 1639 if (Allocator::IsObjectResurrectionForbidden()) |
| 1640 return; |
| 1641 |
| 1642 T* old_end = end(); | 1642 T* old_end = end(); |
| 1643 Base::AllocateBuffer(new_capacity); | 1643 Base::AllocateBuffer(new_capacity); |
| 1644 if (begin() != old_buffer) { | 1644 if (begin() != old_buffer) { |
| 1645 ANNOTATE_NEW_BUFFER(begin(), Capacity(), size_); | 1645 ANNOTATE_NEW_BUFFER(begin(), Capacity(), size_); |
| 1646 TypeOperations::Move(old_buffer, old_end, begin()); | 1646 TypeOperations::Move(old_buffer, old_end, begin()); |
| 1647 ClearUnusedSlots(old_buffer, old_end); | 1647 ClearUnusedSlots(old_buffer, old_end); |
| 1648 ANNOTATE_DELETE_BUFFER(old_buffer, old_capacity, size_); | 1648 ANNOTATE_DELETE_BUFFER(old_buffer, old_capacity, size_); |
| 1649 } | 1649 } |
| 1650 } else { | 1650 } else { |
| 1651 Base::ResetBufferPointer(); | 1651 Base::ResetBufferPointer(); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 visitor, *const_cast<T*>(buffer_entry)); | 1913 visitor, *const_cast<T*>(buffer_entry)); |
| 1914 CheckUnusedSlots(Buffer() + size(), Buffer() + Capacity()); | 1914 CheckUnusedSlots(Buffer() + size(), Buffer() + Capacity()); |
| 1915 } | 1915 } |
| 1916 } | 1916 } |
| 1917 | 1917 |
| 1918 } // namespace WTF | 1918 } // namespace WTF |
| 1919 | 1919 |
| 1920 using WTF::Vector; | 1920 using WTF::Vector; |
| 1921 | 1921 |
| 1922 #endif // WTF_Vector_h | 1922 #endif // WTF_Vector_h |
| OLD | NEW |