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

Unified Diff: runtime/lib/array.dart

Issue 13863012: Refactor List.setRange function. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase 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: runtime/lib/array.dart
diff --git a/runtime/lib/array.dart b/runtime/lib/array.dart
index 2478686b5aa44cdc324ffb97ca7b9119b801f570..fe18eab4abf674b149533e3ace08aefc34844dee 100644
--- a/runtime/lib/array.dart
+++ b/runtime/lib/array.dart
@@ -65,10 +65,14 @@ class _ObjectArray<E> implements List<E> {
}
// List interface.
- void setRange(int start, int length, List<E> from, [int startFrom = 0]) {
- if (length < 0) {
- throw new ArgumentError("negative length $length");
+ void setRange(int start, int end, List<E> from, [int startFrom = 0]) {
+ if (start < 0 || start > this.length) {
+ throw new RangeError.range(start, 0, this.length);
}
+ if (end < 0 || end > this.length) {
+ throw new RangeError.range(end, start, this.length);
+ }
+ int length = end - start;
if (from is _ObjectArray) {
_copyFromObjectArray(from, startFrom, start, length);
} else {
@@ -317,7 +321,7 @@ class _ImmutableArray<E> implements List<E> {
"Cannot modify an immutable array");
}
- void setRange(int start, int length, List<E> from, [int startFrom = 0]) {
+ void setRange(int start, int end, List<E> from, [int startFrom = 0]) {
throw new UnsupportedError(
"Cannot modify an immutable array");
}

Powered by Google App Engine
This is Rietveld 408576698