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

Unified Diff: runtime/lib/convert_patch.dart

Issue 368483004: Avoid unnecessary copying when parsing doubles. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Also use the native parse directly in JSON parsing. Created 6 years, 6 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 | runtime/lib/double.cc » ('j') | runtime/lib/double.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/convert_patch.dart
diff --git a/runtime/lib/convert_patch.dart b/runtime/lib/convert_patch.dart
index d5683e11f87ee093796388d968bb3e95a2f75da4..8dc448423942594ae253b7815875bc07177d4790 100644
--- a/runtime/lib/convert_patch.dart
+++ b/runtime/lib/convert_patch.dart
@@ -558,14 +558,14 @@ class _JsonParser {
listener.handleNumber(intSign * intValue);
return position;
}
- // Consider whether we can have an int/double.parse that works on part of
- // a string, to avoid creating the substring.
- String literal = source.substring(start, position);
// This correctly creates -0.0 for doubles.
- listener.handleNumber(double.parse(literal));
+ listener.handleNumber(_parseDouble(source, start, position));
return position;
}
+ static double _parseDouble(String str,
+ int start, int end) native "Double_parse";
+
void fail(int position, [String message]) {
if (message == null) message = "Unexpected character";
listener.fail(source, position, message);
« no previous file with comments | « no previous file | runtime/lib/double.cc » ('j') | runtime/lib/double.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698