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

Unified Diff: sdk/lib/internal/iterable.dart

Issue 656773002: Add concurrent modification check to ListMixin/IterableMixin.reduce. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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: sdk/lib/internal/iterable.dart
diff --git a/sdk/lib/internal/iterable.dart b/sdk/lib/internal/iterable.dart
index 58301a7ca1cdfb1441491e738b545e073fe7f241..8e0f4b28ff2124b0de5b46c329e123b09d00dfd2 100644
--- a/sdk/lib/internal/iterable.dart
+++ b/sdk/lib/internal/iterable.dart
@@ -175,10 +175,15 @@ abstract class ListIterable<E> extends IterableBase<E>
Iterable map(f(E element)) => new MappedListIterable(this, f);
E reduce(E combine(var value, E element)) {
+ int length = this.length;
if (length == 0) throw IterableElementError.noElement();
E value = elementAt(0);
for (int i = 1; i < length; i++) {
value = combine(value, elementAt(i));
+ if (length != this.length) {
+ throw new ConcurrentModificationError(this);
+ }
+
}
return value;
}

Powered by Google App Engine
This is Rietveld 408576698