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

Unified Diff: runtime/lib/integers_patch.dart

Issue 581593002: Add argument error for int.parse(null). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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: runtime/lib/integers_patch.dart
diff --git a/runtime/lib/integers_patch.dart b/runtime/lib/integers_patch.dart
index 4ac46dc74ce7d8a629ff4fac86102ad09ea1a839..c49dbf3c107700f6c3a62b05ccd6e3a842d71d34 100644
--- a/runtime/lib/integers_patch.dart
+++ b/runtime/lib/integers_patch.dart
@@ -22,17 +22,17 @@ patch class int {
return null; // Empty.
}
}
- int smiLimit = is64Bit() ? 18 : 9;
+ var smiLimit = is64Bit() ? 18 : 9;
if ((last - ix) >= smiLimit) {
return null; // May not fit into a Smi.
}
var result = 0;
for (int i = ix; i <= last; i++) {
- var c = str.codeUnitAt(i) - 0x30;
- if ((c > 9) || (c < 0)) {
+ var c = 0x30 ^ str.codeUnitAt(i);
+ if (9 < c) {
return null;
}
- result = result * 10 + c;
+ result = 10 * result + c;
}
return sign * result;
}
@@ -62,6 +62,7 @@ patch class int {
/* patch */ static int parse(String source,
{ int radix,
int onError(String str) }) {
+ if (identical(source, null)) throw new ArgumentError(source);
srdjan 2014/09/17 15:13:53 Please explain why you are using identical instead
Lasse Reichstein Nielsen 2014/09/17 15:28:04 Ack, a silly attempt to see if it made any differe
if (radix == null) {
int result;
if (source.isNotEmpty) result = _parse(source);
« 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