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

Side by Side Diff: sdk/lib/_internal/compiler/js_lib/js_array.dart

Issue 1104063002: Make EfficientLength public, as EfficientLengthIterable. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comment. Created 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of _interceptors; 5 part of _interceptors;
6 6
7 /** 7 /**
8 * The interceptor class for [List]. The compiler recognizes this 8 * The interceptor class for [List]. The compiler recognizes this
9 * class as an interceptor, and changes references to [:this:] to 9 * class as an interceptor, and changes references to [:this:] to
10 * actually use the receiver of the method, which is generated as an extra 10 * actually use the receiver of the method, which is generated as an extra
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if (index is !int) throw new ArgumentError(index); 118 if (index is !int) throw new ArgumentError(index);
119 if (index < 0 || index > length) { 119 if (index < 0 || index > length) {
120 throw new RangeError.value(index); 120 throw new RangeError.value(index);
121 } 121 }
122 JS('void', r'#.splice(#, 0, #)', this, index, value); 122 JS('void', r'#.splice(#, 0, #)', this, index, value);
123 } 123 }
124 124
125 void insertAll(int index, Iterable<E> iterable) { 125 void insertAll(int index, Iterable<E> iterable) {
126 checkGrowable('insertAll'); 126 checkGrowable('insertAll');
127 RangeError.checkValueInInterval(index, 0, this.length, "index"); 127 RangeError.checkValueInInterval(index, 0, this.length, "index");
128 if (iterable is! EfficientLength) { 128 if (iterable is! EfficientLengthIterable) {
129 iterable = iterable.toList(); 129 iterable = iterable.toList();
130 } 130 }
131 int insertionLength = iterable.length; 131 int insertionLength = iterable.length;
132 this.length += insertionLength; 132 this.length += insertionLength;
133 int end = index + insertionLength; 133 int end = index + insertionLength;
134 this.setRange(end, this.length, this, index); 134 this.setRange(end, this.length, this, index);
135 this.setRange(index, end, iterable); 135 this.setRange(index, end, iterable);
136 } 136 }
137 137
138 void setAll(int index, Iterable<E> iterable) { 138 void setAll(int index, Iterable<E> iterable) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 RangeError.checkValidRange(start, end, this.length); 433 RangeError.checkValidRange(start, end, this.length);
434 for (int i = start; i < end; i++) { 434 for (int i = start; i < end; i++) {
435 // Store is safe since [fillValue] type has been checked as parameter. 435 // Store is safe since [fillValue] type has been checked as parameter.
436 JS('', '#[#] = #', this, i, fillValue); 436 JS('', '#[#] = #', this, i, fillValue);
437 } 437 }
438 } 438 }
439 439
440 void replaceRange(int start, int end, Iterable<E> replacement) { 440 void replaceRange(int start, int end, Iterable<E> replacement) {
441 checkGrowable('replace range'); 441 checkGrowable('replace range');
442 RangeError.checkValidRange(start, end, this.length); 442 RangeError.checkValidRange(start, end, this.length);
443 if (replacement is! EfficientLength) { 443 if (replacement is! EfficientLengthIterable) {
444 replacement = replacement.toList(); 444 replacement = replacement.toList();
445 } 445 }
446 int removeLength = end - start; 446 int removeLength = end - start;
447 int insertLength = replacement.length; 447 int insertLength = replacement.length;
448 if (removeLength >= insertLength) { 448 if (removeLength >= insertLength) {
449 int delta = removeLength - insertLength; 449 int delta = removeLength - insertLength;
450 int insertEnd = start + insertLength; 450 int insertEnd = start + insertLength;
451 int newLength = this.length - delta; 451 int newLength = this.length - delta;
452 this.setRange(start, insertEnd, replacement); 452 this.setRange(start, insertEnd, replacement);
453 if (delta != 0) { 453 if (delta != 0) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 640
641 if (_index >= length) { 641 if (_index >= length) {
642 _current = null; 642 _current = null;
643 return false; 643 return false;
644 } 644 }
645 _current = _iterable[_index]; 645 _current = _iterable[_index];
646 _index++; 646 _index++;
647 return true; 647 return true;
648 } 648 }
649 } 649 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698