Skip to content

Commit

Permalink
fix(codegen): use ryu-js for f64 to string
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Jul 14, 2024
1 parent 06197b8 commit 084ab76
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/oxc_codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ doctest = false
oxc_ast = { workspace = true }
oxc_span = { workspace = true }
oxc_allocator = { workspace = true }
oxc_syntax = { workspace = true }
oxc_syntax = { workspace = true, features = ["to_js_string"] }
oxc_sourcemap = { workspace = true }
oxc_mangler = { workspace = true }

Expand Down
4 changes: 3 additions & 1 deletion crates/oxc_codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,8 +1184,10 @@ impl<'a, const MINIFY: bool> Gen<MINIFY> for NumericLiteral<'a> {
}

// TODO: refactor this with less allocations
// <https://github.com/evanw/esbuild/blob/360d47230813e67d0312ad754cad2b6ee09b151b/internal/js_printer/js_printer.go#L3472>
fn print_non_negative_float<const MINIFY: bool>(value: f64, _p: &Codegen<{ MINIFY }>) -> String {
let mut result = value.to_string();
use oxc_syntax::number::ToJsString;
let mut result = value.to_js_string();
let chars = result.as_bytes();
let len = chars.len();
let dot = chars.iter().position(|&c| c == b'.');
Expand Down

0 comments on commit 084ab76

Please sign in to comment.