From 91c454b7ff757feff03ad0253b7ef8ffa0096688 Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Thu, 28 Oct 2021 21:15:41 +0500 Subject: [PATCH] Performance improvement --- include/fmt/chrono.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 0ac173ff..874dc4d9 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -1459,8 +1459,9 @@ template class tm_writer { } auto tm_hour12() const noexcept -> int { - auto hour = tm_hour() % 12; - return hour == 0 ? 12 : hour; + const auto h = tm_hour(); + const auto z = h < 12 ? h : h - 12; + return z == 0 ? 12 : z; } // POSIX and the C Standard are unclear or inconsistent about what %C and %y