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

Unified Diff: runtime/vm/object.cc

Issue 473673004: Avoid UTF-8 decoding in num.toString. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 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/vm/object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 39368)
+++ runtime/vm/object.cc (working copy)
@@ -15958,6 +15958,21 @@
}
+RawString* Number::ToString(Heap::Space space) const {
+ // Refactoring can avoid Zone::Alloc and strlen, but gains are insignificant.
+ const char* cstr = ToCString();
+ intptr_t len = strlen(cstr);
+ // Resulting string is ASCII ...
+#ifdef DEBUG
+ for (intptr_t i = 0; i < len; ++i) {
+ ASSERT(static_cast<uint8_t>(cstr[i]) < 128);
+ }
+#endif // DEBUG
+ // ... which is a subset of Latin-1.
+ return String::FromLatin1(reinterpret_cast<const uint8_t*>(cstr), len, space);
+}
+
+
const char* Double::ToCString() const {
if (isnan(value())) {
return "NaN";
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698