Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: third_party/WebKit/Source/wtf/HashCountedSet.h

Issue 2249393002: Remove one of copyToVector for HashCountedSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 128
129 template <typename T, typename U, typename V, typename W> 129 template <typename T, typename U, typename V, typename W>
130 inline void HashCountedSet<T, U, V, W>::removeAll(iterator it) 130 inline void HashCountedSet<T, U, V, W>::removeAll(iterator it)
131 { 131 {
132 if (it == end()) 132 if (it == end())
133 return; 133 return;
134 134
135 m_impl.remove(it); 135 m_impl.remove(it);
136 } 136 }
137 137
138 template <typename T, typename U, typename V, typename W, typename VectorType>
139 inline void copyToVector(const HashCountedSet<T, U, V, W>& collection, VectorTyp e& vector)
140 {
141 typedef typename HashCountedSet<T, U, V, W>::const_iterator iterator;
142
143 {
144 // Disallow GC across resize allocation, see crbug.com/568173
145 typename VectorType::GCForbiddenScope scope;
146 vector.resize(collection.size());
147 }
148
149 iterator it = collection.begin();
150 iterator end = collection.end();
151 for (unsigned i = 0; it != end; ++it, ++i)
152 vector[i] = *it;
153 }
154
155 template <typename Value, typename HashFunctions, typename Traits, typename Allo cator, size_t inlineCapacity, typename VectorAllocator> 138 template <typename Value, typename HashFunctions, typename Traits, typename Allo cator, size_t inlineCapacity, typename VectorAllocator>
156 inline void copyToVector(const HashCountedSet<Value, HashFunctions, Traits, Allo cator>& collection, Vector<Value, inlineCapacity, VectorAllocator>& vector) 139 inline void copyToVector(const HashCountedSet<Value, HashFunctions, Traits, Allo cator>& collection, Vector<Value, inlineCapacity, VectorAllocator>& vector)
157 { 140 {
158 typedef typename HashCountedSet<Value, HashFunctions, Traits, Allocator>::co nst_iterator iterator; 141 typedef typename HashCountedSet<Value, HashFunctions, Traits, Allocator>::co nst_iterator iterator;
159 142
160 { 143 {
161 // Disallow GC across resize allocation, see crbug.com/568173 144 // Disallow GC across resize allocation, see crbug.com/568173
162 typename Vector<Value, inlineCapacity, VectorAllocator>::GCForbiddenScop e scope; 145 typename Vector<Value, inlineCapacity, VectorAllocator>::GCForbiddenScop e scope;
163 vector.resize(collection.size()); 146 vector.resize(collection.size());
164 } 147 }
165 148
166 iterator it = collection.begin(); 149 iterator it = collection.begin();
167 iterator end = collection.end(); 150 iterator end = collection.end();
168 for (unsigned i = 0; it != end; ++it, ++i) 151 for (unsigned i = 0; it != end; ++it, ++i)
169 vector[i] = (*it).key; 152 vector[i] = (*it).key;
170 } 153 }
171 154
172 } // namespace WTF 155 } // namespace WTF
173 156
174 using WTF::HashCountedSet; 157 using WTF::HashCountedSet;
175 158
176 #endif // WTF_HashCountedSet_h 159 #endif // WTF_HashCountedSet_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698