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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_array.dart

Issue 13872007: Refactor removeRange. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebuild dom. Created 7 years, 8 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/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 c3065eb261c1e0cd8c9de9c8ab5b1e2a7c76c40f..7902ed906516ffbbc06d6bbdffe613672769b057 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_array.dart
@@ -216,29 +216,20 @@ class JSArray<E> extends Interceptor implements List<E>, JSIndexable {
E max([int compare(E a, E b)]) => IterableMixinWorkaround.max(this, compare);
- void removeRange(int start, int length) {
- checkGrowable(this, 'removeRange');
- 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.
- if (start is !int) throw new ArgumentError(start);
- if (length is !int) throw new ArgumentError(length);
- if (length < 0) throw new ArgumentError(length);
- var receiverLength = this.length;
- if (start < 0 || start >= receiverLength) {
- throw new RangeError.value(start);
+ void removeRange(int start, int end) {
+ int receiverLength = this.length;
+ if (start < 0 || start > receiverLength) {
+ throw new RangeError.range(start, 0, receiverLength);
}
- if (start + length > receiverLength) {
- throw new RangeError.value(start + length);
+ if (end < start || end > receiverLength) {
+ throw new RangeError.range(end, start, receiverLength);
}
Arrays.copy(this,
- start + length,
+ end,
this,
start,
- receiverLength - length - start);
- this.length = receiverLength - length;
+ receiverLength - end);
+ this.length = receiverLength - (end - start);
}
void setRange(int start, int end, List<E> from, [int startFrom = 0]) {

Powered by Google App Engine
This is Rietveld 408576698