Chromium Code Reviews| 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); |