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

Unified Diff: sdk/lib/core/errors.dart

Issue 864463002: Create string efficiently from Uint16List/View. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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/core/errors.dart
diff --git a/sdk/lib/core/errors.dart b/sdk/lib/core/errors.dart
index 0ac18808e643191f51e96665a57656df8ad4e2bf..fd46ee4d3405fbb30b942445f896959704fd46b0 100644
--- a/sdk/lib/core/errors.dart
+++ b/sdk/lib/core/errors.dart
@@ -297,18 +297,25 @@ class RangeError extends ArgumentError {
*
* The [startName] and [endName] defaults to `"start"` and `"end"`,
* respectively.
+ *
+ * Returns the actual `end` value, which is `length` if `end` is `null`,
+ * and `end` otherwise.
*/
- static void checkValidRange(int start, int end, int length,
+ static int checkValidRange(int start, int end, int length,
[String startName, String endName,
String message]) {
if (start < 0 || start > length) {
if (startName == null) startName = "start";
throw new RangeError.range(start, 0, length, startName, message);
}
- if (end != null && (end < start || end > length)) {
- if (endName == null) endName = "end";
- throw new RangeError.range(end, start, length, endName, message);
+ if (end != null) {
+ if (end < start || end > length) {
+ if (endName == null) endName = "end";
+ throw new RangeError.range(end, start, length, endName, message);
+ }
+ return end;
}
+ return length;
}
/**

Powered by Google App Engine
This is Rietveld 408576698