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

Side by Side Diff: runtime/lib/growable_array.dart

Issue 14468004: Fix missing concurrency check in [].forEach. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added comment about iteration order of lists. Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class _GrowableObjectArray<T> implements List<T> { 5 class _GrowableObjectArray<T> implements List<T> {
6 factory _GrowableObjectArray._uninstantiable() { 6 factory _GrowableObjectArray._uninstantiable() {
7 throw new UnsupportedError( 7 throw new UnsupportedError(
8 "GrowableObjectArray can only be allocated by the VM"); 8 "GrowableObjectArray can only be allocated by the VM");
9 } 9 }
10 10
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 _setData(new_data); 231 _setData(new_data);
232 } 232 }
233 233
234 // Collection interface. 234 // Collection interface.
235 235
236 bool contains(T element) { 236 bool contains(T element) {
237 return IterableMixinWorkaround.contains(this, element); 237 return IterableMixinWorkaround.contains(this, element);
238 } 238 }
239 239
240 void forEach(f(T element)) { 240 void forEach(f(T element)) {
241 // TODO(srdjan): Use IterableMixinWorkaround.forEach(this, f); 241 int initialLength = length;
242 // Accessing the list directly improves DeltaBlue performance by 25%.
243 for (int i = 0; i < length; i++) { 242 for (int i = 0; i < length; i++) {
244 f(this[i]); 243 f(this[i]);
244 if (length != initialLength) throw new ConcurrentModificationError(this);
hausner 2013/04/25 23:07:17 This is not sufficient to detect modifications. Th
Ivan Posva 2013/04/26 05:58:22 I think the only concern is that length could chan
245 } 245 }
246 } 246 }
247 247
248 String join([String separator = ""]) { 248 String join([String separator = ""]) {
249 if (isEmpty) return ""; 249 if (isEmpty) return "";
250 if (this.length == 1) return "${this[0]}"; 250 if (this.length == 1) return "${this[0]}";
251 StringBuffer buffer = new StringBuffer(); 251 StringBuffer buffer = new StringBuffer();
252 if (separator.isEmpty) { 252 if (separator.isEmpty) {
253 for (int i = 0; i < this.length; i++) { 253 for (int i = 0; i < this.length; i++) {
254 buffer.write("${this[i]}"); 254 buffer.write("${this[i]}");
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 350 }
351 351
352 Set<T> toSet() { 352 Set<T> toSet() {
353 return new Set<T>.from(this); 353 return new Set<T>.from(this);
354 } 354 }
355 355
356 Map<int, T> asMap() { 356 Map<int, T> asMap() {
357 return IterableMixinWorkaround.asMapList(this); 357 return IterableMixinWorkaround.asMapList(this);
358 } 358 }
359 } 359 }
OLDNEW
« no previous file with comments | « runtime/lib/array.dart ('k') | runtime/lib/typeddata.dart » ('j') | sdk/lib/core/list.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698