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

Unified Diff: sdk/lib/internal/lists.dart

Issue 745573002: Create generic check methods for RangeError causing checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix long line Created 6 years, 1 month 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
« no previous file with comments | « sdk/lib/internal/list.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/internal/lists.dart
diff --git a/sdk/lib/internal/lists.dart b/sdk/lib/internal/lists.dart
index f821616bd638ad8f2adaaa753547620e6f8c2d15..0f5d8e745233727a55f629280250e00ea9d08c81 100644
--- a/sdk/lib/internal/lists.dart
+++ b/sdk/lib/internal/lists.dart
@@ -75,25 +75,16 @@ class Lists {
}
static void indicesCheck(List a, int start, int end) {
- if (start < 0 || start > a.length) {
- throw new RangeError.range(start, 0, a.length);
- }
- if (end != null && (end < start || end > a.length)) {
- throw new RangeError.range(end, start, a.length);
- }
+ RangeError.checkValidRange(start, end, a.length);
}
static void rangeCheck(List a, int start, int length) {
- if (length < 0) {
- throw new ArgumentError("negative length $length");
- }
- if (start < 0 ) {
- String message = "$start must be greater than or equal to 0";
- throw new RangeError(message);
- }
+ RangeError.checkNotNegative(length);
+ RangeError.checkNotNegative(start);
if (start + length > a.length) {
- String message = "$start + $length must be in the range [0..${a.length})";
- throw new RangeError(message);
+ String message = "$start + $length must be in the range [0..${a.length}]";
+ throw new RangeError.range(length, 0, a.length - start,
+ "length", message);
}
}
}
« no previous file with comments | « sdk/lib/internal/list.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698