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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: runtime/lib/growable_array.dart
diff --git a/runtime/lib/growable_array.dart b/runtime/lib/growable_array.dart
index 95594b60c81805cc6ed27cfdb59a5ab4f1ac1e47..f65380b68be6a79ab7cf3a89ec1840c875679073 100644
--- a/runtime/lib/growable_array.dart
+++ b/runtime/lib/growable_array.dart
@@ -238,10 +238,10 @@ class _GrowableObjectArray<T> implements List<T> {
}
void forEach(f(T element)) {
- // TODO(srdjan): Use IterableMixinWorkaround.forEach(this, f);
- // Accessing the list directly improves DeltaBlue performance by 25%.
+ int initialLength = length;
for (int i = 0; i < length; i++) {
f(this[i]);
+ 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
}
}
« 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