From 9d8f267770be93b7f34bb01655ad804466f487c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Juli=C3=A1n=20Espina?= Date: Sun, 24 Nov 2024 02:22:48 +0000 Subject: [PATCH] Migrate to fast-float2 (#4052) --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- core/engine/Cargo.toml | 2 +- core/engine/src/builtins/number/globals.rs | 2 +- core/parser/Cargo.toml | 2 +- core/parser/src/lexer/number.rs | 2 +- core/string/Cargo.toml | 2 +- core/string/src/lib.rs | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a98149275e2..28eabf55454 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -365,7 +365,7 @@ dependencies = [ "criterion", "dashmap", "either", - "fast-float", + "fast-float2", "fixed_decimal", "float-cmp", "futures-lite 2.5.0", @@ -518,7 +518,7 @@ dependencies = [ "boa_interner", "boa_macros", "boa_profiler", - "fast-float", + "fast-float2", "icu_properties", "num-bigint", "num-traits", @@ -552,7 +552,7 @@ dependencies = [ name = "boa_string" version = "0.19.0" dependencies = [ - "fast-float", + "fast-float2", "paste", "rustc-hash 2.0.0", "sptr", @@ -1231,10 +1231,10 @@ dependencies = [ ] [[package]] -name = "fast-float" -version = "0.2.0" +name = "fast-float2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95765f67b4b18863968b4a1bd5bb576f732b29a4a28c7cd84c09fa3e2875f33c" +checksum = "f8eb564c5c7423d25c886fb561d1e4ee69f72354d16918afa32c08811f6b6a55" [[package]] name = "fastrand" diff --git a/Cargo.toml b/Cargo.toml index d2bc014fd16..57afce14e19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/core/engine/Cargo.toml b/core/engine/Cargo.toml index 5e7596f6c2c..9a0d603e427 100644 --- a/core/engine/Cargo.toml +++ b/core/engine/Cargo.toml @@ -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 diff --git a/core/engine/src/builtins/number/globals.rs b/core/engine/src/builtins/number/globals.rs index 9e603200245..6fa8813f8d9 100644 --- a/core/engine/src/builtins/number/globals.rs +++ b/core/engine/src/builtins/number/globals.rs @@ -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::(s).map_or_else( + Ok(fast_float2::parse_partial::(s).map_or_else( |_| JsValue::nan(), |(f, len)| { if len > 0 { diff --git a/core/parser/Cargo.toml b/core/parser/Cargo.toml index 32b70a3918b..6da2ef48ee8 100644 --- a/core/parser/Cargo.toml +++ b/core/parser/Cargo.toml @@ -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 diff --git a/core/parser/src/lexer/number.rs b/core/parser/src/lexer/number.rs index c944eb878b8..787392001bb 100644 --- a/core/parser/src/lexer/number.rs +++ b/core/parser/src/lexer/number.rs @@ -402,7 +402,7 @@ impl Tokenizer 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, diff --git a/core/string/Cargo.toml b/core/string/Cargo.toml index 0bee6f3615c..60268b4cc00 100644 --- a/core/string/Cargo.toml +++ b/core/string/Cargo.toml @@ -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 diff --git a/core/string/src/lib.rs b/core/string/src/lib.rs index 1d4ed920e9f..f39288289ce 100644 --- a/core/string/src/lib.rs +++ b/core/string/src/lib.rs @@ -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.