| Index: sdk/lib/_internal/compiler/implementation/lib/js_array.dart
|
| diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_array.dart b/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
|
| index 9b73f4080cbd0388225a53463aec53ec2e9cfde1..70e47d640aa25f6cb9a412a9c71f738610f5ebba 100644
|
| --- a/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
|
| +++ b/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
|
| @@ -156,30 +156,7 @@ class JSArray<E> implements List<E> {
|
|
|
| void insertRange(int start, int length, [E initialValue]) {
|
| checkGrowable(this, 'insertRange');
|
| - if (length == 0) {
|
| - return;
|
| - }
|
| - if (length is !int) throw new ArgumentError(length);
|
| - if (length < 0) throw new ArgumentError(length);
|
| - if (start is !int) throw new ArgumentError(start);
|
| -
|
| - var receiver = this;
|
| - var receiverLength = receiver.length;
|
| - if (start < 0 || start > receiverLength) {
|
| - throw new RangeError.value(start);
|
| - }
|
| - receiver.length = receiverLength + length;
|
| - Arrays.copy(receiver,
|
| - start,
|
| - receiver,
|
| - start + length,
|
| - receiverLength - start);
|
| - if (initialValue != null) {
|
| - for (int i = start; i < start + length; i++) {
|
| - receiver[i] = initialValue;
|
| - }
|
| - }
|
| - receiver.length = receiverLength + length;
|
| + return listInsertRange(this, start, length, initialValue);
|
| }
|
|
|
| E get first {
|
| @@ -229,7 +206,21 @@ class JSArray<E> implements List<E> {
|
|
|
| void setRange(int start, int length, List<E> from, [int startFrom = 0]) {
|
| checkMutable(this, 'set range');
|
| - IterableMixinWorkaround.setRangeList(this, start, length, from, startFrom);
|
| + if (length == 0) return;
|
| + checkNull(start); // TODO(ahe): This is not specified but co19 tests it.
|
| + checkNull(length); // TODO(ahe): This is not specified but co19 tests it.
|
| + checkNull(from); // TODO(ahe): This is not specified but co19 tests it.
|
| + checkNull(startFrom); // TODO(ahe): This is not specified but co19 tests it.
|
| + if (start is !int) throw new ArgumentError(start);
|
| + if (length is !int) throw new ArgumentError(length);
|
| + if (startFrom is !int) throw new ArgumentError(startFrom);
|
| + if (length < 0) throw new ArgumentError(length);
|
| + if (start < 0) throw new RangeError.value(start);
|
| + if (start + length > this.length) {
|
| + throw new RangeError.value(start + length);
|
| + }
|
| +
|
| + Arrays.copy(from, startFrom, this, start, length);
|
| }
|
|
|
| bool any(bool f(E element)) => IterableMixinWorkaround.any(this, f);
|
| @@ -244,11 +235,13 @@ class JSArray<E> implements List<E> {
|
| }
|
|
|
| int indexOf(E element, [int start = 0]) {
|
| - return IterableMixinWorkaround.indexOfList(this, element, start);
|
| + if (start is !int) throw new ArgumentError(start);
|
| + return Arrays.indexOf(this, element, start, length);
|
| }
|
|
|
| int lastIndexOf(E element, [int start]) {
|
| - return IterableMixinWorkaround.lastIndexOfList(this, element, start);
|
| + if (start == null) start = this.length - 1;
|
| + return Arrays.lastIndexOf(this, element, start);
|
| }
|
|
|
| bool contains(E other) {
|
|
|