Browse Source

Migrate to fast-float2 (#4052)

pull/4053/head
José Julián Espina 1 week ago committed by GitHub
parent
commit
9d8f267770
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      Cargo.lock
  2. 2
      Cargo.toml
  3. 2
      core/engine/Cargo.toml
  4. 2
      core/engine/src/builtins/number/globals.rs
  5. 2
      core/parser/Cargo.toml
  6. 2
      core/parser/src/lexer/number.rs
  7. 2
      core/string/Cargo.toml
  8. 2
      core/string/src/lib.rs

12
Cargo.lock generated

@ -365,7 +365,7 @@ dependencies = [
"criterion", "criterion",
"dashmap", "dashmap",
"either", "either",
"fast-float", "fast-float2",
"fixed_decimal", "fixed_decimal",
"float-cmp", "float-cmp",
"futures-lite 2.5.0", "futures-lite 2.5.0",
@ -518,7 +518,7 @@ dependencies = [
"boa_interner", "boa_interner",
"boa_macros", "boa_macros",
"boa_profiler", "boa_profiler",
"fast-float", "fast-float2",
"icu_properties", "icu_properties",
"num-bigint", "num-bigint",
"num-traits", "num-traits",
@ -552,7 +552,7 @@ dependencies = [
name = "boa_string" name = "boa_string"
version = "0.19.0" version = "0.19.0"
dependencies = [ dependencies = [
"fast-float", "fast-float2",
"paste", "paste",
"rustc-hash 2.0.0", "rustc-hash 2.0.0",
"sptr", "sptr",
@ -1231,10 +1231,10 @@ dependencies = [
] ]
[[package]] [[package]]
name = "fast-float" name = "fast-float2"
version = "0.2.0" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95765f67b4b18863968b4a1bd5bb576f732b29a4a28c7cd84c09fa3e2875f33c" checksum = "f8eb564c5c7423d25c886fb561d1e4ee69f72354d16918afa32c08811f6b6a55"
[[package]] [[package]]
name = "fastrand" name = "fastrand"

2
Cargo.toml

@ -50,7 +50,7 @@ arbitrary = "1"
bitflags = "2.5.0" bitflags = "2.5.0"
clap = "4.5.21" clap = "4.5.21"
colored = "2.1.0" colored = "2.1.0"
fast-float = "0.2.0" fast-float2 = "0.2.3"
hashbrown = "0.15.1" hashbrown = "0.15.1"
indexmap = { version = "2.6.0", default-features = false } indexmap = { version = "2.6.0", default-features = false }
indoc = "2.0.5" indoc = "2.0.5"

2
core/engine/Cargo.toml

@ -86,7 +86,7 @@ num-integer.workspace = true
bitflags.workspace = true bitflags.workspace = true
indexmap = { workspace = true, features = ["std"] } indexmap = { workspace = true, features = ["std"] }
ryu-js.workspace = true ryu-js.workspace = true
fast-float.workspace = true fast-float2.workspace = true
once_cell = { workspace = true, features = ["std"] } once_cell = { workspace = true, features = ["std"] }
tap.workspace = true tap.workspace = true
sptr.workspace = true sptr.workspace = true

2
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 // Prevent fast_float from parsing "inf", "+inf" as Infinity and "-inf" as -Infinity
Ok(JsValue::nan()) Ok(JsValue::nan())
} else { } else {
Ok(fast_float::parse_partial::<f64, _>(s).map_or_else( Ok(fast_float2::parse_partial::<f64, _>(s).map_or_else(
|_| JsValue::nan(), |_| JsValue::nan(),
|(f, len)| { |(f, len)| {
if len > 0 { if len > 0 {

2
core/parser/Cargo.toml

@ -16,7 +16,7 @@ boa_macros.workspace = true
boa_ast.workspace = true boa_ast.workspace = true
boa_profiler.workspace = true boa_profiler.workspace = true
rustc-hash = { workspace = true, features = ["std"] } rustc-hash = { workspace = true, features = ["std"] }
fast-float.workspace = true fast-float2.workspace = true
num-traits.workspace = true num-traits.workspace = true
bitflags.workspace = true bitflags.workspace = true
num-bigint.workspace = true num-bigint.workspace = true

2
core/parser/src/lexer/number.rs

@ -402,7 +402,7 @@ impl<R> Tokenizer<R> for NumberLiteral {
// casting precisely to check if the float doesn't lose info on truncation // casting precisely to check if the float doesn't lose info on truncation
#[allow(clippy::cast_possible_truncation)] #[allow(clippy::cast_possible_truncation)]
NumericKind::Rational /* base: 10 */ => { 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; let int_val = val as i32;
// The truncated float should be identically to the non-truncated float for the conversion to be loss-less, // The truncated float should be identically to the non-truncated float for the conversion to be loss-less,

2
core/string/Cargo.toml

@ -16,7 +16,7 @@ rustc-hash = { workspace = true, features = ["std"] }
sptr.workspace = true sptr.workspace = true
static_assertions.workspace = true static_assertions.workspace = true
paste.workspace = true paste.workspace = true
fast-float.workspace = true fast-float2.workspace = true
[lints] [lints]
workspace = true workspace = true

2
core/string/src/lib.rs

@ -717,7 +717,7 @@ impl JsString {
return value; 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. /// Allocates a new [`RawJsString`] with an internal capacity of `str_len` chars.

Loading…
Cancel
Save