| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef TraceWrapperMember_h | 5 #ifndef TraceWrapperMember_h |
| 6 #define TraceWrapperMember_h | 6 #define TraceWrapperMember_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptWrappableVisitor.h" | 8 #include "bindings/core/v8/ScriptWrappableVisitor.h" |
| 9 #include "platform/heap/HeapAllocator.h" | 9 #include "platform/heap/HeapAllocator.h" |
| 10 | 10 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 * which is not copyable but has to be explicitly specified. | 87 * which is not copyable but has to be explicitly specified. |
| 88 */ | 88 */ |
| 89 template <typename T> | 89 template <typename T> |
| 90 void swap(HeapVector<TraceWrapperMember<T>>& a, | 90 void swap(HeapVector<TraceWrapperMember<T>>& a, |
| 91 HeapVector<TraceWrapperMember<T>>& b, | 91 HeapVector<TraceWrapperMember<T>>& b, |
| 92 void* parentForA, | 92 void* parentForA, |
| 93 void* parentForB) { | 93 void* parentForB) { |
| 94 HeapVector<TraceWrapperMember<T>> temp; | 94 HeapVector<TraceWrapperMember<T>> temp; |
| 95 temp.reserveCapacity(a.size()); | 95 temp.reserveCapacity(a.size()); |
| 96 for (auto item : a) { | 96 for (auto item : a) { |
| 97 temp.append(TraceWrapperMember<T>(parentForB, item.get())); | 97 temp.push_back(TraceWrapperMember<T>(parentForB, item.get())); |
| 98 } | 98 } |
| 99 a.clear(); | 99 a.clear(); |
| 100 a.reserveCapacity(b.size()); | 100 a.reserveCapacity(b.size()); |
| 101 for (auto item : b) { | 101 for (auto item : b) { |
| 102 a.append(TraceWrapperMember<T>(parentForA, item.get())); | 102 a.push_back(TraceWrapperMember<T>(parentForA, item.get())); |
| 103 } | 103 } |
| 104 b.clear(); | 104 b.clear(); |
| 105 b.reserveCapacity(temp.size()); | 105 b.reserveCapacity(temp.size()); |
| 106 for (auto item : temp) { | 106 for (auto item : temp) { |
| 107 b.append(TraceWrapperMember<T>(parentForB, item.get())); | 107 b.push_back(TraceWrapperMember<T>(parentForB, item.get())); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * Swaps two HeapVectors, one containing TraceWrapperMember and one with | 112 * Swaps two HeapVectors, one containing TraceWrapperMember and one with |
| 113 * regular Members. The custom swap function is required as | 113 * regular Members. The custom swap function is required as |
| 114 * TraceWrapperMember contains ownership information which is not copyable | 114 * TraceWrapperMember contains ownership information which is not copyable |
| 115 * but has to be explicitly specified. | 115 * but has to be explicitly specified. |
| 116 */ | 116 */ |
| 117 template <typename T> | 117 template <typename T> |
| 118 void swap(HeapVector<TraceWrapperMember<T>>& a, | 118 void swap(HeapVector<TraceWrapperMember<T>>& a, |
| 119 HeapVector<Member<T>>& b, | 119 HeapVector<Member<T>>& b, |
| 120 void* parentForA) { | 120 void* parentForA) { |
| 121 HeapVector<TraceWrapperMember<T>> temp; | 121 HeapVector<TraceWrapperMember<T>> temp; |
| 122 temp.reserveCapacity(a.size()); | 122 temp.reserveCapacity(a.size()); |
| 123 for (auto item : a) { | 123 for (auto item : a) { |
| 124 temp.append(TraceWrapperMember<T>(nullptr, item.get())); | 124 temp.push_back(TraceWrapperMember<T>(nullptr, item.get())); |
| 125 } | 125 } |
| 126 a.clear(); | 126 a.clear(); |
| 127 a.reserveCapacity(b.size()); | 127 a.reserveCapacity(b.size()); |
| 128 for (auto item : b) { | 128 for (auto item : b) { |
| 129 a.append(TraceWrapperMember<T>(parentForA, item.get())); | 129 a.push_back(TraceWrapperMember<T>(parentForA, item.get())); |
| 130 } | 130 } |
| 131 b.clear(); | 131 b.clear(); |
| 132 b.reserveCapacity(temp.size()); | 132 b.reserveCapacity(temp.size()); |
| 133 for (auto item : temp) { | 133 for (auto item : temp) { |
| 134 b.append(item.get()); | 134 b.push_back(item.get()); |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 } // namespace blink | 138 } // namespace blink |
| 139 | 139 |
| 140 #endif // TraceWrapperMember_h | 140 #endif // TraceWrapperMember_h |
| OLD | NEW |