Index: sdk/lib/collection/list.dart |
diff --git a/sdk/lib/collection/list.dart b/sdk/lib/collection/list.dart |
index dbf3355d8901cfc77ead2ceb8a5e5eec86a58db4..818388d274684ec7c98f8001e31a6dbf3175ac65 100644 |
--- a/sdk/lib/collection/list.dart |
+++ b/sdk/lib/collection/list.dart |
@@ -277,7 +277,7 @@ abstract class ListMixin<E> implements List<E> { |
void remove(Object element) { |
for (int i = 0; i < this.length; i++) { |
if (this[i] == element) { |
- this.setRange(i, this.length - i - 1, this, i + 1); |
+ this.setRange(i, i + this.length - 1, this, i + 1); |
this.length -= 1; |
return; |
} |
@@ -382,7 +382,7 @@ abstract class ListMixin<E> implements List<E> { |
int moveLength = oldLength - start; |
this.length += length; |
if (moveLength > 0) { |
- this.setRange(start + length, moveLength, this, start); |
+ this.setRange(start + length, oldLength, this, start); |
} |
for (int i = 0; i < length; i++) { |
this[start + i] = initialValue; |
@@ -397,7 +397,7 @@ abstract class ListMixin<E> implements List<E> { |
throw new RangeError.range(length, 0, this.length - start); |
} |
int end = start + length; |
- setRange(start, this.length - end, this, end); |
+ setRange(start, this.length - length, this, end); |
this.length -= length; |
} |
@@ -407,16 +407,17 @@ abstract class ListMixin<E> implements List<E> { |
} |
} |
- void setRange(int start, int length, List<E> from, [int startFrom]) { |
+ void setRange(int start, int end, List<E> from, [int startFrom]) { |
if (start < 0 || start > this.length) { |
throw new RangeError.range(start, 0, this.length); |
} |
- if (length < 0 || start + length > this.length) { |
- throw new RangeError.range(length, 0, this.length - start); |
+ if (end < 0 || end > this.length) { |
+ throw new RangeError.range(end, start, this.length); |
} |
if (startFrom == null) { |
startFrom = 0; |
} |
+ int length = end - start; |
if (startFrom < 0 || startFrom + length > from.length) { |
throw new RangeError.range(startFrom, 0, from.length - length); |
} |