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

Unified Diff: runtime/lib/double_patch.dart

Issue 15868003: Revert "Rewrite double.parse." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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/lib/double.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/double_patch.dart
diff --git a/runtime/lib/double_patch.dart b/runtime/lib/double_patch.dart
index 8fb5560870fae22fac6b74615227245feb4505a6..e56f45dc74c234ef81628d2bb72d63c120c5c409 100644
--- a/runtime/lib/double_patch.dart
+++ b/runtime/lib/double_patch.dart
@@ -6,45 +6,15 @@
// VM implementation of double.
patch class double {
-
- static double _native_parse(_OneByteString string) native "Double_parse";
-
- static double _parse(var str) {
- str = str.trim();
-
- if (str.length == 0) return null;
-
- final ccid = str._cid;
- _OneByteString oneByteString;
- // TODO(floitsch): Allow _ExternalOneByteStrings. As of May 2013 they don't
- // have any _classId.
- if (ccid != _OneByteString._classId) {
- int length = str.length;
- var s = _OneByteString._allocate(length);
- for (int i = 0; i < length; i++) {
- int currentUnit = str.codeUnitAt(i);
- // All valid trimmed double strings must be ASCII.
- if (currentUnit < 128) {
- s._setAt(i, currentUnit);
- } else {
- return null;
- }
- }
- oneByteString = s;
- } else {
- oneByteString = str;
- }
-
- return _native_parse(oneByteString);
- }
+ static double _parse(String string) native "Double_parse";
/* patch */ static double parse(String str,
[double handleError(String str)]) {
- var result = _parse(str);
- if (result == null) {
- if (handleError == null) throw new FormatException(str);
+ if (handleError == null) return _parse(str);
+ try {
+ return _parse(str);
+ } on FormatException {
return handleError(str);
}
- return result;
}
}
« no previous file with comments | « runtime/lib/double.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698