From 8b7a55a03cb38fa4ab4e9309d38f0fd24a51814a Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Fri, 18 Nov 2022 15:33:44 -0500 Subject: [PATCH] Minor optimization. --- include/fast_float/parse_number.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index 0a8092f..0e22afc 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -83,6 +83,7 @@ fastfloat_really_inline bool rounds_to_nearest() noexcept { // value so that 1 + x should round to 1 would do (after accounting for excess // precision, as in 387). static volatile float fmin = std::numeric_limits::min(); + float fmini = fmin; // we copy it so that it gets loaded at most once. // // Explanation: // Only when fegetround() == FE_TONEAREST do we have that @@ -105,7 +106,7 @@ fastfloat_really_inline bool rounds_to_nearest() noexcept { // // Note: This may fail to be accurate if fast-math has been // enabled, as rounding conventions may not apply. - return (fmin + 1.0f == 1.0f - fmin); + return (fmini + 1.0f == 1.0f - fmini); } } // namespace detail