diff --git a/include/fmt/format.h b/include/fmt/format.h index 7720371d..a2fc9621 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1382,7 +1382,7 @@ inline auto thousands_sep(locale_ref loc) -> thousands_sep_result { } template -FMT_API auto decimal_point_impl(locale_ref loc) -> Char; +FMT_API FMT_NOINLINE auto decimal_point_impl(locale_ref loc) -> Char; template inline auto decimal_point(locale_ref loc) -> Char { return Char(decimal_point_impl(loc)); } @@ -3398,6 +3398,20 @@ FMT_CONSTEXPR20 void format_hexfloat(Float value, format_specs specs, format_hexfloat(static_cast(value), specs, buf); } +template +FMT_CONSTEXPR auto write_hexfloat(OutputIt out, string_view s, + const format_specs& specs, locale_ref loc) + -> OutputIt { + Char point = FMT_USE_LOCALE && specs.localized() + ? detail::decimal_point(loc) + : Char('.'); + return write_padded( + out, specs, s.size(), [=](reserve_iterator it) { + for (char c : s) *it++ = c == '.' ? point : static_cast(c); + return it; + }); +} + constexpr auto fractional_part_rounding_thresholds(int index) -> uint32_t { // For checking rounding thresholds. // The kth entry is chosen to be the smallest integer such that the @@ -3758,14 +3772,8 @@ FMT_CONSTEXPR20 auto write(OutputIt out, T value, format_specs specs, buffer.push_back(specs.upper() ? 'X' : 'x'); } format_hexfloat(convert_float(value), specs, buffer); - Char point = FMT_USE_LOCALE && specs.localized() - ? detail::decimal_point(loc) - : Char('.'); - return write_padded( - out, specs, buffer.size(), [&](reserve_iterator it) { - for (char c : buffer) *it++ = c == '.' ? point : static_cast(c); - return it; - }); + return write_hexfloat(out, {buffer.data(), buffer.size()}, specs, + loc); } if (specs.type() == presentation_type::exp) {