about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTrevor Gross <t.gross35@gmail.com>2024-07-16 20:10:09 -0500
committerGitHub <noreply@github.com>2024-07-16 20:10:09 -0500
commitfe1dc02163e001092ae4e7306ec30b05e9960657 (patch)
treee0e3af9c74458cd84adb95173efb5bcc6b35e9d3
parent689d27293ac04905d230b8fce89aadb42f96a29a (diff)
parent33f1d9d554dad10ebc11453d1595c97dba72d211 (diff)
downloadrust-fe1dc02163e001092ae4e7306ec30b05e9960657.tar.gz
rust-fe1dc02163e001092ae4e7306ec30b05e9960657.zip
Rollup merge of #126271 - diondokter:dec2flt-skip-fast-path, r=tgross35
Skip fast path for dec2flt when optimize_for_size

Tracking issue: https://github.com/rust-lang/rust/issues/125612

Skip the fast algorithm when optimizing for size.
When compiling for https://github.com/quartiq/stabilizer I get these numbers:

Before
```
   text    data     bss     dec     hex filename
 192192       8   49424  241624   3afd8 dual-iir
```

After
```
   text    data     bss     dec     hex filename
 191632       8   49424  241064   3ada8 dual-iir
```

This saves 560 bytes.
-rw-r--r--library/core/src/num/dec2flt/mod.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/library/core/src/num/dec2flt/mod.rs b/library/core/src/num/dec2flt/mod.rs
index a4bc8b1c9b0..9aac2332dce 100644
--- a/library/core/src/num/dec2flt/mod.rs
+++ b/library/core/src/num/dec2flt/mod.rs
@@ -250,8 +250,10 @@ pub fn dec2flt<F: RawFloat>(s: &str) -> Result<F, ParseFloatError> {
         None => return Err(pfe_invalid()),
     };
     num.negative = negative;
-    if let Some(value) = num.try_fast_path::<F>() {
-        return Ok(value);
+    if !cfg!(feature = "optimize_for_size") {
+        if let Some(value) = num.try_fast_path::<F>() {
+            return Ok(value);
+        }
     }
 
     // If significant digits were truncated, then we can have rounding error