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

Unified Diff: src/conversions.cc

Issue 619005: Fast algorithm for double->string conversion. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 10 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 | « src/checks.h ('k') | src/diy_fp.h » ('j') | src/diy_fp.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/conversions.cc
===================================================================
--- src/conversions.cc (revision 3886)
+++ src/conversions.cc (working copy)
@@ -33,6 +33,8 @@
#include "factory.h"
#include "scanner.h"
+#include "grisu3.h"
+
namespace v8 {
namespace internal {
@@ -382,8 +384,17 @@
int decimal_point;
int sign;
- char* decimal_rep = dtoa(v, 0, 0, &decimal_point, &sign, NULL);
- int length = StrLength(decimal_rep);
+ char* decimal_rep;
+ bool used_dtoa = false;
+ char grisu_buffer[kGrisu3MaximalLength + 1];
+ int length;
+ if (grisu3(v, grisu_buffer, &sign, &length, &decimal_point)) {
+ decimal_rep = &grisu_buffer[0];
fschneider 2010/02/22 16:25:24 You can just write: decimal_rep = grisu_buffer;
Florian Loitsch 2010/02/23 09:05:10 Done.
+ } else {
+ decimal_rep = dtoa(v, 0, 0, &decimal_point, &sign, NULL);
+ used_dtoa = true;
+ length = StrLength(decimal_rep);
+ }
if (sign) builder.AddCharacter('-');
@@ -418,7 +429,7 @@
builder.AddFormatted("%d", exponent);
}
- freedtoa(decimal_rep);
+ if (used_dtoa) freedtoa(decimal_rep);
}
}
return builder.Finalize();
« no previous file with comments | « src/checks.h ('k') | src/diy_fp.h » ('j') | src/diy_fp.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698