From 9b3d9f7b1a4ddb59449166800c5281ab28cd4fbc Mon Sep 17 00:00:00 2001 From: HedgehogInTheCPP Date: Sat, 29 Aug 2026 17:33:00 +0300 Subject: [PATCH] add fastfloat_noinline from https://github.com/fastfloat/fast_float/pull/403 my fork don't need any additional from this PR because it's already simd optimized more strictly. --- include/fast_float/digit_comparison.h | 9 +++++---- include/fast_float/float_common.h | 8 +++++++- include/fast_float/parse_number.h | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/fast_float/digit_comparison.h b/include/fast_float/digit_comparison.h index 710aa6e..435a2c8 100644 --- a/include/fast_float/digit_comparison.h +++ b/include/fast_float/digit_comparison.h @@ -379,8 +379,9 @@ parse_mantissa(bigint &result, const parsed_number_string_t &num) noexcept { } template -inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa positive_digit_comp( - bigint &bigmant, adjusted_mantissa am, am_pow_t const exponent) noexcept { +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa +positive_digit_comp(bigint &bigmant, adjusted_mantissa am, + am_pow_t const exponent) noexcept { FASTFLOAT_ASSERT(bigmant.pow10(exponent)); bool truncated; am.mantissa = bigmant.hi64(truncated); @@ -407,7 +408,7 @@ inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa positive_digit_comp( // we then need to scale by `2^(f- e)`, and then the two significant digits // are of the same magnitude. template -inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa +fastfloat_really_inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa negative_digit_comp(bigint &real_digits, adjusted_mantissa am, am_pow_t const real_exp) noexcept { // get the value of `b`, rounded down, and get a bigint representation of b+h @@ -472,7 +473,7 @@ negative_digit_comp(bigint &real_digits, adjusted_mantissa am, // the actual digits. we then compare the big integer representations // of both, and use that to direct rounding. template -inline FASTFLOAT_CONSTEXPR20 adjusted_mantissa digit_comp( +fastfloat_noinline FASTFLOAT_CONSTEXPR20 adjusted_mantissa digit_comp( parsed_number_string_t const &num, adjusted_mantissa am) noexcept { // remove the invalid exponent bias am.power2 -= invalid_am_bias; diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index 10cc861..6f74c25 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -230,10 +230,16 @@ static_assert(FASTFLOAT_X86_SIMD == 20 || FASTFLOAT_X86_SIMD == 42 || #endif #endif + #ifdef FASTFLOAT_VISUAL_STUDIO #define fastfloat_really_inline __forceinline -#else +#define fastfloat_noinline __declspec(noinline) +#elif defined(__GNUC__) || defined(__clang__) #define fastfloat_really_inline inline __attribute__((always_inline)) +#define fastfloat_noinline __attribute__((noinline)) +#else +#define fastfloat_really_inline inline +#define fastfloat_noinline #endif // Branch-probability hint marking the rare slow-path branches as cold, so the diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index 548db8d..7faa3a2 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -331,7 +331,7 @@ from_chars_advanced(parsed_number_string_t const &pns, T &value) noexcept { // and the am.power2<0 digit_comp recompute, so both slow branches collapse to // one helper call. template -FASTFLOAT_CONSTEXPR20 from_chars_result_t +static fastfloat_noinline FASTFLOAT_CONSTEXPR20 from_chars_result_t parse_number_slow_path(UC const *first, UC const *last, T &value, parse_options_t const options #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN