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

Unified Diff: tool/input_sdk/lib/collection/list.dart

Issue 1943563002: Updates for js_array (Closed) Base URL: https://github.com/dart-lang/dev_compiler@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | tool/input_sdk/lib/internal/iterable.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tool/input_sdk/lib/collection/list.dart
diff --git a/tool/input_sdk/lib/collection/list.dart b/tool/input_sdk/lib/collection/list.dart
index c856de9a78555e7fd00e1fd084d28033ca20ff9e..ac1be05af0fa511cd1e45d92d084d61b0cf4dd19 100644
--- a/tool/input_sdk/lib/collection/list.dart
+++ b/tool/input_sdk/lib/collection/list.dart
@@ -244,8 +244,12 @@ abstract class ListMixin<E> implements List<E> {
}
void addAll(Iterable<E> iterable) {
+ int i = this.length;
for (E element in iterable) {
- this[this.length++] = element;
+ assert(this.length == i || (throw new ConcurrentModificationError(this)));
+ this.length = i + 1;
+ this[i] = element;
+ i++;
}
}
@@ -472,7 +476,7 @@ abstract class ListMixin<E> implements List<E> {
void insertAll(int index, Iterable<E> iterable) {
RangeError.checkValueInInterval(index, 0, length, "index");
- if (iterable is EfficientLength) {
+ if (iterable is! EfficientLength || identical(iterable, this)) {
iterable = iterable.toList();
}
int insertionLength = iterable.length;
@@ -480,6 +484,12 @@ abstract class ListMixin<E> implements List<E> {
// will end up being modified but the operation not complete. Unless we
// always go through a "toList" we can't really avoid that.
this.length += insertionLength;
+ if (iterable.length != insertionLength) {
+ // If the iterable's length is linked to this list's length somehow,
+ // we can't insert one in the other.
+ this.length -= insertionLength;
+ throw new ConcurrentModificationError(iterable);
+ }
setRange(index + insertionLength, this.length, this, index);
setAll(index, iterable);
}
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | tool/input_sdk/lib/internal/iterable.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698