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

Unified Diff: sdk/lib/_internal/compiler/js_lib/core_patch.dart

Issue 1066843007: Reuse RangeError.checkValidRange in dart2js core_patch.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/js_lib/core_patch.dart
diff --git a/sdk/lib/_internal/compiler/js_lib/core_patch.dart b/sdk/lib/_internal/compiler/js_lib/core_patch.dart
index a3f151312f3ba21692967657af164c8164aa9acb..4f472c5b23feb4c996e948dcddb2e4cadaac168e 100644
--- a/sdk/lib/_internal/compiler/js_lib/core_patch.dart
+++ b/sdk/lib/_internal/compiler/js_lib/core_patch.dart
@@ -315,7 +315,7 @@ class String {
static String _stringFromJSArray(List list, int start, int endOrNull) {
int len = list.length;
- int end = _checkBounds(len, start, endOrNull);
+ int end = RangeError.checkValidRange(start, endOrNull, len);
if (start > 0 || end < len) {
list = list.sublist(start, end);
}
@@ -325,22 +325,10 @@ class String {
static String _stringFromUint8List(
NativeUint8List charCodes, int start, int endOrNull) {
int len = charCodes.length;
- int end = _checkBounds(len, start, endOrNull);
+ int end = RangeError.checkValidRange(start, endOrNull, len);
return Primitives.stringFromNativeUint8List(charCodes, start, end);
}
- static int _checkBounds(int len, int start, int end) {
- if (start < 0 || start > len) {
- throw new RangeError.range(start, 0, len);
- }
- if (end == null) {
- end = len;
- } else if (end < start || end > len) {
- throw new RangeError.range(end, start, len);
- }
- return end;
- }
-
static String _stringFromIterable(Iterable<int> charCodes,
int start, int end) {
if (start < 0) throw new RangeError.range(start, 0, charCodes.length);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698