Skip to content

Commit

Permalink
Rollup merge of rust-lang#126271 - diondokter:dec2flt-skip-fast-path,…
Browse files Browse the repository at this point in the history
… r=tgross35

Skip fast path for dec2flt when optimize_for_size

Tracking issue: rust-lang#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.
  • Loading branch information
tgross35 authored Jul 17, 2024
2 parents 8490c84 + 32a1b07 commit 00d603f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/src/num/dec2flt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 00d603f

Please sign in to comment.