Skip to content

Commit fca6214

Browse files
committed
0.8.5 testing perf with dtoa (this breaks some tests, but the JSON is
still valid)
1 parent d587fed commit fca6214

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ license = "MIT"
99

1010
[dependencies]
1111
itoa = "0.1"
12+
dtoa = "0.1"

src/codegen.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::num::FpCategory;
33
use JsonValue;
44

55
extern crate itoa;
6+
extern crate dtoa;
67

78
const QU: u8 = b'"';
89
const BS: u8 = b'\\';
@@ -92,12 +93,13 @@ pub trait Generator {
9293
if num.fract() == 0.0 && num.abs() < 1e19 {
9394
itoa::write(self.get_writer(), num as i64).unwrap();
9495
} else {
95-
let abs = num.abs();
96-
if abs < 1e-15 || abs > 1e19 {
97-
write!(self.get_writer(), "{:e}", num).unwrap();
98-
} else {
99-
write!(self.get_writer(), "{}", num).unwrap();
100-
}
96+
dtoa::write(self.get_writer(), num).unwrap();
97+
// let abs = num.abs();
98+
// if abs < 1e-15 || abs > 1e19 {
99+
// write!(self.get_writer(), "{:e}", num).unwrap();
100+
// } else {
101+
// write!(self.get_writer(), "{}", num).unwrap();
102+
// }
101103
}
102104
},
103105
FpCategory::Zero => {

0 commit comments

Comments
 (0)