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

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

Issue 2725813002: (CANCELED) Forbid GC during copyToVector() (Closed)
Patch Set: Created 3 years, 9 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 | third_party/WebKit/Source/wtf/HashSet.h » ('j') | 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 156
157 template <typename Value, 157 template <typename Value,
158 typename HashFunctions, 158 typename HashFunctions,
159 typename Traits, 159 typename Traits,
160 typename Allocator, 160 typename Allocator,
161 typename VectorType> 161 typename VectorType>
162 inline void copyToVector( 162 inline void copyToVector(
163 const HashCountedSet<Value, HashFunctions, Traits, Allocator>& collection, 163 const HashCountedSet<Value, HashFunctions, Traits, Allocator>& collection,
164 VectorType& vector) { 164 VectorType& vector) {
165 { 165 // Disallow GC across resize and iterations, see crbug.com/568173
166 // Disallow GC across resize allocation, see crbug.com/568173 166 typename VectorType::GCForbiddenScope scope;
167 typename VectorType::GCForbiddenScope scope; 167
168 vector.resize(collection.size()); 168 vector.resize(collection.size());
169 }
170 169
171 auto it = collection.begin(); 170 auto it = collection.begin();
172 auto end = collection.end(); 171 auto end = collection.end();
173 for (unsigned i = 0; it != end; ++it, ++i) 172 for (unsigned i = 0; it != end; ++it, ++i)
174 vector[i] = (*it).key; 173 vector[i] = (*it).key;
175 } 174 }
176 175
177 template <typename T, typename U, typename V, typename W> 176 template <typename T, typename U, typename V, typename W>
178 inline Vector<T> HashCountedSet<T, U, V, W>::asVector() const { 177 inline Vector<T> HashCountedSet<T, U, V, W>::asVector() const {
179 Vector<T> vector; 178 Vector<T> vector;
180 copyToVector(*this, vector); 179 copyToVector(*this, vector);
181 return vector; 180 return vector;
182 } 181 }
183 182
184 } // namespace WTF 183 } // namespace WTF
185 184
186 using WTF::HashCountedSet; 185 using WTF::HashCountedSet;
187 186
188 #endif // WTF_HashCountedSet_h 187 #endif // WTF_HashCountedSet_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/HashSet.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698