From f59392581eea764e4cd3242ee0e4897fc76575fe Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 18 Feb 2026 10:35:17 -0600 Subject: [PATCH] Remove max significant digits and zero cutoff checks in float formatting functions for improved simplicity and performance. This change streamlines the `format_f32` and `format_f64` functions, enhancing the overall efficiency of float serialization in JSON. --- src/json.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/json.rs b/src/json.rs index 9b3da17a..960e217a 100644 --- a/src/json.rs +++ b/src/json.rs @@ -147,7 +147,6 @@ const F64_FLOAT_OPTIONS: Options = Options::builder() .inf_string(Some(b"Infinity")) .positive_exponent_break(SCI_POSITIVE_BREAK) .negative_exponent_break(SCI_NEGATIVE_BREAK) - .max_significant_digits(NonZeroUsize::new(15)) .round_mode(RoundMode::Round) .build_strict(); @@ -163,9 +162,6 @@ fn format_f32(v: f32) -> String { } fn format_f64(v: f64) -> String { - if v.is_finite() && v.abs() >= 1e308 { - return format!("{v:e}"); - } let mut buffer = [0u8; F64_BUF_SIZE]; let digits = v.to_lexical_with_options::(&mut buffer, &F64_FLOAT_OPTIONS); std::str::from_utf8(digits)