| 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 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 return *this; | 756 return *this; |
| 757 | 757 |
| 758 if (size() > other.size()) | 758 if (size() > other.size()) |
| 759 shrink(other.size()); | 759 shrink(other.size()); |
| 760 else if (other.size() > capacity()) { | 760 else if (other.size() > capacity()) { |
| 761 clear(); | 761 clear(); |
| 762 reserveCapacity(other.size()); | 762 reserveCapacity(other.size()); |
| 763 ASSERT(begin()); | 763 ASSERT(begin()); |
| 764 } | 764 } |
| 765 | 765 |
| 766 // Works around an assert in VS2010. See https://connect.microsoft.com/VisualStu
dio/feedback/details/558044/std-copy-should-not-check-dest-when-first-last | |
| 767 #if COMPILER(MSVC) && defined(_ITERATOR_DEBUG_LEVEL) && _ITERATOR_DEBUG_LEVEL | |
| 768 if (!begin()) | |
| 769 return *this; | |
| 770 #endif | |
| 771 | |
| 772 std::copy(other.begin(), other.begin() + size(), begin()); | 766 std::copy(other.begin(), other.begin() + size(), begin()); |
| 773 TypeOperations::uninitializedCopy(other.begin() + size(), other.end(), e
nd()); | 767 TypeOperations::uninitializedCopy(other.begin() + size(), other.end(), e
nd()); |
| 774 m_size = other.size(); | 768 m_size = other.size(); |
| 775 | 769 |
| 776 return *this; | 770 return *this; |
| 777 } | 771 } |
| 778 | 772 |
| 779 inline bool typelessPointersAreEqual(const void* a, const void* b) { return
a == b; } | 773 inline bool typelessPointersAreEqual(const void* a, const void* b) { return
a == b; } |
| 780 | 774 |
| 781 template<typename T, size_t inlineCapacity, typename Allocator> | 775 template<typename T, size_t inlineCapacity, typename Allocator> |
| 782 template<size_t otherCapacity> | 776 template<size_t otherCapacity> |
| 783 Vector<T, inlineCapacity, Allocator>& Vector<T, inlineCapacity, Allocator>::
operator=(const Vector<T, otherCapacity, Allocator>& other) | 777 Vector<T, inlineCapacity, Allocator>& Vector<T, inlineCapacity, Allocator>::
operator=(const Vector<T, otherCapacity, Allocator>& other) |
| 784 { | 778 { |
| 785 // If the inline capacities match, we should call the more specific | 779 // If the inline capacities match, we should call the more specific |
| 786 // template. If the inline capacities don't match, the two objects | 780 // template. If the inline capacities don't match, the two objects |
| 787 // shouldn't be allocated the same address. | 781 // shouldn't be allocated the same address. |
| 788 ASSERT(!typelessPointersAreEqual(&other, this)); | 782 ASSERT(!typelessPointersAreEqual(&other, this)); |
| 789 | 783 |
| 790 if (size() > other.size()) | 784 if (size() > other.size()) |
| 791 shrink(other.size()); | 785 shrink(other.size()); |
| 792 else if (other.size() > capacity()) { | 786 else if (other.size() > capacity()) { |
| 793 clear(); | 787 clear(); |
| 794 reserveCapacity(other.size()); | 788 reserveCapacity(other.size()); |
| 795 ASSERT(begin()); | 789 ASSERT(begin()); |
| 796 } | 790 } |
| 797 | 791 |
| 798 // Works around an assert in VS2010. See https://connect.microsoft.com/VisualStu
dio/feedback/details/558044/std-copy-should-not-check-dest-when-first-last | |
| 799 #if COMPILER(MSVC) && defined(_ITERATOR_DEBUG_LEVEL) && _ITERATOR_DEBUG_LEVEL | |
| 800 if (!begin()) | |
| 801 return *this; | |
| 802 #endif | |
| 803 | |
| 804 std::copy(other.begin(), other.begin() + size(), begin()); | 792 std::copy(other.begin(), other.begin() + size(), begin()); |
| 805 TypeOperations::uninitializedCopy(other.begin() + size(), other.end(), e
nd()); | 793 TypeOperations::uninitializedCopy(other.begin() + size(), other.end(), e
nd()); |
| 806 m_size = other.size(); | 794 m_size = other.size(); |
| 807 | 795 |
| 808 return *this; | 796 return *this; |
| 809 } | 797 } |
| 810 | 798 |
| 811 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) | 799 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) |
| 812 template<typename T, size_t inlineCapacity, typename Allocator> | 800 template<typename T, size_t inlineCapacity, typename Allocator> |
| 813 Vector<T, inlineCapacity, Allocator>::Vector(Vector<T, inlineCapacity, Alloc
ator>&& other) | 801 Vector<T, inlineCapacity, Allocator>::Vector(Vector<T, inlineCapacity, Alloc
ator>&& other) |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 struct NeedsTracing<Vector<T, N> > { | 1195 struct NeedsTracing<Vector<T, N> > { |
| 1208 static const bool value = false; | 1196 static const bool value = false; |
| 1209 }; | 1197 }; |
| 1210 #endif | 1198 #endif |
| 1211 | 1199 |
| 1212 } // namespace WTF | 1200 } // namespace WTF |
| 1213 | 1201 |
| 1214 using WTF::Vector; | 1202 using WTF::Vector; |
| 1215 | 1203 |
| 1216 #endif // WTF_Vector_h | 1204 #endif // WTF_Vector_h |
| OLD | NEW |