Skip to content

Commit

Permalink
Migrate to fast-float2 (#4052)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 authored Nov 24, 2024
1 parent 8f1d8d4 commit 9d8f267
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ arbitrary = "1"
bitflags = "2.5.0"
clap = "4.5.21"
colored = "2.1.0"
fast-float = "0.2.0"
fast-float2 = "0.2.3"
hashbrown = "0.15.1"
indexmap = { version = "2.6.0", default-features = false }
indoc = "2.0.5"
Expand Down
2 changes: 1 addition & 1 deletion core/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ num-integer.workspace = true
bitflags.workspace = true
indexmap = { workspace = true, features = ["std"] }
ryu-js.workspace = true
fast-float.workspace = true
fast-float2.workspace = true
once_cell = { workspace = true, features = ["std"] }
tap.workspace = true
sptr.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion core/engine/src/builtins/number/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ pub(crate) fn parse_float(
// Prevent fast_float from parsing "inf", "+inf" as Infinity and "-inf" as -Infinity
Ok(JsValue::nan())
} else {
Ok(fast_float::parse_partial::<f64, _>(s).map_or_else(
Ok(fast_float2::parse_partial::<f64, _>(s).map_or_else(
|_| JsValue::nan(),
|(f, len)| {
if len > 0 {
Expand Down
2 changes: 1 addition & 1 deletion core/parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ boa_macros.workspace = true
boa_ast.workspace = true
boa_profiler.workspace = true
rustc-hash = { workspace = true, features = ["std"] }
fast-float.workspace = true
fast-float2.workspace = true
num-traits.workspace = true
bitflags.workspace = true
num-bigint.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion core/parser/src/lexer/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ impl<R> Tokenizer<R> for NumberLiteral {
// casting precisely to check if the float doesn't lose info on truncation
#[allow(clippy::cast_possible_truncation)]
NumericKind::Rational /* base: 10 */ => {
let val: f64 = fast_float::parse(num_str).expect("Failed to parse float after checks");
let val: f64 = fast_float2::parse(num_str).expect("Failed to parse float after checks");
let int_val = val as i32;

// The truncated float should be identically to the non-truncated float for the conversion to be loss-less,
Expand Down
2 changes: 1 addition & 1 deletion core/string/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rustc-hash = { workspace = true, features = ["std"] }
sptr.workspace = true
static_assertions.workspace = true
paste.workspace = true
fast-float.workspace = true
fast-float2.workspace = true

[lints]
workspace = true
Expand Down
2 changes: 1 addition & 1 deletion core/string/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ impl JsString {
return value;
}

fast_float::parse(string).unwrap_or(f64::NAN)
fast_float2::parse(string).unwrap_or(f64::NAN)
}

/// Allocates a new [`RawJsString`] with an internal capacity of `str_len` chars.
Expand Down

0 comments on commit 9d8f267

Please sign in to comment.