mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[ VM / Service ] Updated JSONWriter::PrintValue(double) to use double_conversion instead of Printf.
Fixes #31737 Change-Id: If70b7b6bdd1e977bda310a2b0566dcd48c6b3c6a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101101 Commit-Queue: Ben Konyi <bkonyi@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
58ef1db2ba
commit
bdc91968a2
|
@ -61,7 +61,7 @@ TEST_CASE(JSON_JSONStream_Primitives) {
|
|||
JSONArray jsarr(&js);
|
||||
jsarr.AddValue(1.0);
|
||||
}
|
||||
EXPECT_STREQ("[1.000000]", js.ToCString());
|
||||
EXPECT_STREQ("[1.0]", js.ToCString());
|
||||
}
|
||||
{
|
||||
JSONStream js;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "platform/assert.h"
|
||||
|
||||
#include "platform/unicode.h"
|
||||
#include "vm/double_conversion.h"
|
||||
#include "vm/json_writer.h"
|
||||
#include "vm/object.h"
|
||||
|
||||
|
@ -117,8 +118,13 @@ void JSONWriter::PrintValue64(int64_t i) {
|
|||
}
|
||||
|
||||
void JSONWriter::PrintValue(double d) {
|
||||
// Max length of a double in characters (including \0).
|
||||
// See double_conversion.cc.
|
||||
const size_t kBufferLen = 25;
|
||||
char buffer[kBufferLen];
|
||||
DoubleToCString(d, buffer, kBufferLen);
|
||||
PrintCommaIfNeeded();
|
||||
buffer_.Printf("%f", d);
|
||||
buffer_.Printf("%s", buffer);
|
||||
}
|
||||
|
||||
static const char base64_digits[65] =
|
||||
|
|
|
@ -67,7 +67,7 @@ VM_UNIT_TEST_CASE(Metric_OnDemand) {
|
|||
"{\"type\":\"Counter\",\"name\":\"a.b.c\",\"description\":"
|
||||
"\"foobar\",\"unit\":\"byte\","
|
||||
"\"fixedId\":true,\"id\":\"metrics\\/native\\/a.b.c\""
|
||||
",\"value\":99.000000}",
|
||||
",\"value\":99.0}",
|
||||
json);
|
||||
}
|
||||
Dart_ShutdownIsolate();
|
||||
|
|
Loading…
Reference in a new issue