@@ -147,7 +147,13 @@ macro_rules! from_str_float_impl {
147
147
/// representable floating-point number to the number represented
148
148
/// by `src` (following the same rules for rounding as for the
149
149
/// results of primitive operations).
150
- #[ inline]
150
+ // We add the `#[inline(never)]` attribute, since its content will
151
+ // be filled with that of `dec2flt`, which has #[inline(always)].
152
+ // Since `dec2flt` is generic, a normal inline attribute on this function
153
+ // with `dec2flt` having no attributes results in heavily repeated
154
+ // generation of `dec2flt`, despite the fact only a maximum of 2
155
+ // posiible instances. Adding #[inline(never)] avoids this.
156
+ #[ inline( never) ]
151
157
fn from_str( src: & str ) -> Result <Self , ParseFloatError > {
152
158
dec2flt( src)
153
159
}
@@ -202,12 +208,14 @@ impl fmt::Display for ParseFloatError {
202
208
}
203
209
}
204
210
211
+ #[ inline]
205
212
pub ( super ) fn pfe_empty ( ) -> ParseFloatError {
206
213
ParseFloatError { kind : FloatErrorKind :: Empty }
207
214
}
208
215
209
216
// Used in unit tests, keep public.
210
217
// This is much better than making FloatErrorKind and ParseFloatError::kind public.
218
+ #[ inline]
211
219
pub fn pfe_invalid ( ) -> ParseFloatError {
212
220
ParseFloatError { kind : FloatErrorKind :: Invalid }
213
221
}
@@ -220,6 +228,7 @@ fn biased_fp_to_float<T: RawFloat>(x: BiasedFp) -> T {
220
228
}
221
229
222
230
/// Converts a decimal string into a floating point number.
231
+ #[ inline( always) ] // Will be inlined into a function with `#[inline(never)]`, see above
223
232
pub fn dec2flt < F : RawFloat > ( s : & str ) -> Result < F , ParseFloatError > {
224
233
let mut s = s. as_bytes ( ) ;
225
234
let c = if let Some ( & c) = s. first ( ) {
0 commit comments