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

Unified Diff: sdk/lib/collection/collections.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: sdk/lib/collection/collections.dart
diff --git a/sdk/lib/collection/collections.dart b/sdk/lib/collection/collections.dart
index a5cbfafd7d495f909b914f71b9e9365b29153603..54c7d0bc33d480fd47aa936c1cc8755be62c5fed 100644
--- a/sdk/lib/collection/collections.dart
+++ b/sdk/lib/collection/collections.dart
@@ -369,16 +369,18 @@ class IterableMixinWorkaround {
return new SubListIterable(list, start, end);
}
- static void setRangeList(List list, int start, int length,
+ static void setRangeList(List list, int start, int end,
List from, int startFrom) {
- if (length == 0) return;
-
- if (length < 0) throw new ArgumentError(length);
- if (start < 0) throw new RangeError.value(start);
- if (start + length > list.length) {
- throw new RangeError.value(start + length);
+ if (start < 0 || start > list.length) {
+ throw new RangeError.range(start, 0, list.length);
+ }
+ if (end < start || end > list.length) {
+ throw new RangeError.range(end, start, list.length);
+ }
+ int length = end - start;
+ if (startFrom < 0 || startFrom + length > from.length) {
+ throw new RangeError.range(startFrom, 0, from.length - length);
}
-
Arrays.copy(from, startFrom, list, start, length);
}

Powered by Google App Engine
This is Rietveld 408576698