From 9755307842c9ba195634060556c0a3ffc26b9b5b Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 21 Oct 2020 08:19:21 -0700 Subject: [PATCH] Optimize format_uint --- include/fmt/format.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/fmt/format.h b/include/fmt/format.h index 91487cb3..a51f4eec 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1112,6 +1112,10 @@ Char* format_uint(Char* buffer, detail::fallback_uintptr n, int num_digits, template inline It format_uint(It out, UInt value, int num_digits, bool upper = false) { + if (auto ptr = to_pointer(out, num_digits)) { + format_uint(ptr, value, num_digits, upper); + return out; + } // Buffer should be large enough to hold all digits (digits / BASE_BITS + 1). char buffer[num_bits() / BASE_BITS + 1]; format_uint(buffer, value, num_digits, upper);