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

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: Add tests for external typed-data 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
« no previous file with comments | « runtime/vm/object.cc ('k') | tests/corelib/string_fromcharcodes_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/core/errors.dart
diff --git a/sdk/lib/core/errors.dart b/sdk/lib/core/errors.dart
index 0244ea91753d4e98bf7f9d9ff093520e27a22b5d..a67340660307349df0f7f3866c9965b091d7601f 100644
--- a/sdk/lib/core/errors.dart
+++ b/sdk/lib/core/errors.dart
@@ -300,18 +300,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;
}
/**
« no previous file with comments | « runtime/vm/object.cc ('k') | tests/corelib/string_fromcharcodes_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698