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

Unified Diff: src/inspector/string-16.cc

Issue 2419453002: Revert of [inspector] fix timestamp formatting with non C locales (Closed)
Patch Set: Created 4 years, 2 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/inspector/string-16.h ('k') | src/inspector/v8-console.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/inspector/string-16.cc
diff --git a/src/inspector/string-16.cc b/src/inspector/string-16.cc
index f6084602f421085127603f146f2c9618eb1b1962..e39b87c17f8f035201e9ea4b4835ea3da6c52800 100644
--- a/src/inspector/string-16.cc
+++ b/src/inspector/string-16.cc
@@ -8,10 +8,8 @@
#include <cctype>
#include <cstdlib>
#include <cstring>
-#include <iomanip>
#include <limits>
#include <locale>
-#include <sstream>
#include <string>
#include "src/base/platform/platform.h"
@@ -383,19 +381,26 @@
// static
String16 String16::fromDouble(double number) {
- std::ostringstream s;
- s.imbue(std::locale("C"));
- s << std::fixed << std::setprecision(std::numeric_limits<double>::digits10)
- << number;
- return String16(s.str().c_str());
+ const size_t kBufferSize = 100;
+ char buffer[kBufferSize];
+ v8::base::OS::SNPrintF(buffer, kBufferSize, "%f", number);
+ return String16(buffer);
}
// static
-String16 String16::fromDouble(double number, int precision) {
- std::ostringstream s;
- s.imbue(std::locale("C"));
- s << std::fixed << std::setprecision(precision) << number;
- return String16(s.str().c_str());
+String16 String16::fromDoublePrecision3(double number) {
+ const size_t kBufferSize = 100;
+ char buffer[kBufferSize];
+ v8::base::OS::SNPrintF(buffer, kBufferSize, "%.3g", number);
+ return String16(buffer);
+}
+
+// static
+String16 String16::fromDoublePrecision6(double number) {
+ const size_t kBufferSize = 100;
+ char buffer[kBufferSize];
+ v8::base::OS::SNPrintF(buffer, kBufferSize, "%.6g", number);
+ return String16(buffer);
}
int String16::toInteger(bool* ok) const {
« no previous file with comments | « src/inspector/string-16.h ('k') | src/inspector/v8-console.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698