From d45179c1e7092c6b0d46e4f400fa537377623398 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 17 Jul 2026 11:16:40 -0700 Subject: [PATCH] Merge the two integer write overloads into one The appender and generic-iterator overloads only differed in whether the integer formatting code was inlined. Merge them into a single overload and select write_int_noinline vs inline write_int via if constexpr, keeping the same codegen (out of line for appenders, inlined for compiled formatting) with no size regression. --- include/fmt/format.h | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index b13bc4cf..f2ee623d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2157,29 +2157,19 @@ FMT_CONSTEXPR FMT_NOINLINE auto write_int_noinline(OutputIt out, return write_int(out, arg, specs); } -template ::value && - !std::is_same::value && - !std::is_same::value)> -FMT_CONSTEXPR FMT_INLINE auto write(basic_appender out, T value, - const format_specs& specs, locale_ref loc) - -> basic_appender { - if (specs.localized() && write_loc(out, value, specs, loc)) return out; - return write_int_noinline(out, make_write_int_arg(value, specs.sign()), - specs); -} - -// An inlined version of write used in format string compilation. template ::value && !std::is_same::value && - !std::is_same::value && - !std::is_same>::value)> + !std::is_same::value)> FMT_CONSTEXPR FMT_INLINE auto write(OutputIt out, T value, const format_specs& specs, locale_ref loc) -> OutputIt { if (specs.localized() && write_loc(out, value, specs, loc)) return out; - return write_int(out, make_write_int_arg(value, specs.sign()), specs); + auto arg = make_write_int_arg(value, specs.sign()); + // Out of line for appenders to avoid bloat; inlined for compiled formatting. + if FMT_CONSTEXPR20 (std::is_same>::value) + return write_int_noinline(out, arg, specs); + return write_int(out, arg, specs); } template