From cdf877d4b121f2166cb44f6df0957edc43b6a58a Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 11 Mar 2021 16:44:59 -0800 Subject: [PATCH] Workaround missed optimization opportunity --- include/fmt/format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 83437f63..1e6f851b 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1685,7 +1685,8 @@ template FMT_CONSTEXPR FMT_INLINE OutputIt write_int(OutputIt out, int num_digits, string_view prefix, const basic_format_specs& specs, W write_digits) { - if (specs.width == 0 && specs.precision < 0) { + // Slightly faster check for specs.width == 0 && specs.precision == -1. + if ((specs.width | (specs.precision + 1)) == 0) { auto it = reserve(out, to_unsigned(num_digits) + prefix.size()); if (prefix.size() != 0) it = copy_str(prefix.begin(), prefix.end(), it);