From 4eb97fa4e376b21f2f15adda842167d22dfc9e12 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 5 Sep 2021 16:22:15 -0700 Subject: [PATCH] Reduce code bloat --- include/fmt/format.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index c351c1ba..4ebae7d7 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1611,14 +1611,21 @@ FMT_CONSTEXPR FMT_INLINE auto write_int(OutputIt out, write_int_arg arg, } return out; } +template +FMT_CONSTEXPR FMT_NOINLINE auto write_int_noinline( + OutputIt out, write_int_arg arg, const basic_format_specs& specs, + locale_ref loc) -> OutputIt { + return write_int(out, arg, specs, loc); +} template ::value && !std::is_same::value && std::is_same>::value)> -FMT_CONSTEXPR auto write(OutputIt out, T value, - const basic_format_specs& specs, locale_ref loc) - -> OutputIt { - return write_int(out, make_write_int_arg(value, specs.sign), specs, loc); +FMT_CONSTEXPR FMT_INLINE auto write(OutputIt out, T value, + const basic_format_specs& specs, + locale_ref loc) -> OutputIt { + return write_int_noinline(out, make_write_int_arg(value, specs.sign), specs, + loc); } // An inlined version of write used in format string compilation. template struct formatter> : formatter { } template - auto format(group_digits_view t, FormatContext& ctx) -> decltype(ctx.out()) { + auto format(group_digits_view t, FormatContext& ctx) + -> decltype(ctx.out()) { detail::handle_dynamic_spec(specs_.width, specs_.width_ref, ctx); detail::handle_dynamic_spec( specs_.precision, specs_.precision_ref, ctx); return detail::write_int_localized( - ctx.out(), static_cast>(t.value), 0, - specs_, detail::digit_grouping({"\3", ','})); + ctx.out(), static_cast>(t.value), 0, specs_, + detail::digit_grouping({"\3", ','})); } };