From 98dcc251eb76b70b3e624b0ed799fcd38323dd9a Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 13 Jun 2020 18:23:52 -0700 Subject: [PATCH] Undo branching reduction --- include/fmt/format.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 6998555b..05247744 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2973,9 +2973,14 @@ class format_int { // memcpy is faster than copying character by character. memcpy(ptr, detail::data::digits + index, 2); } + if (value < 10) { + *--ptr = static_cast('0' + value); + return ptr; + } auto index = static_cast(value * 2); - memcpy(ptr - 2, detail::data::digits + index, 2); - return ptr - 1 - (value >= 10 ? 1 : 0); + ptr -= 2; + memcpy(ptr, detail::data::digits + index, 2); + return ptr; } void format_signed(long long value) {