diff --git a/core/src/num/dec2flt/mod.rs b/core/src/num/dec2flt/mod.rs
index a4bc8b1c9b0c3..9aac2332dce0d 100644
--- a/core/src/num/dec2flt/mod.rs
+++ b/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