From c04af4bfc74d2c963a8e353034203aedc4bb6908 Mon Sep 17 00:00:00 2001 From: Junekey Jeon Date: Sun, 13 Feb 2022 03:36:58 -0800 Subject: [PATCH] Simplify remove_trailing_zeros --- include/fmt/format-inl.h | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 6a4b3eb6..a9af399c 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -1876,12 +1876,9 @@ FMT_INLINE int remove_trailing_zeros(uint64_t& n) noexcept { int s = 8; while (true) { auto q = rotr(n32 * mod_inv_25, 2); - if (q <= std::numeric_limits::max() / 100) { - n32 = q; - s += 2; - } else { - break; - } + if (q > std::numeric_limits::max() / 100) break; + n32 = q; + s += 2; } auto q = rotr(n32 * mod_inv_5, 1); if (q <= std::numeric_limits::max() / 10) { @@ -1900,12 +1897,9 @@ FMT_INLINE int remove_trailing_zeros(uint64_t& n) noexcept { int s = 0; while (true) { auto q = rotr(n * mod_inv_25, 2); - if (q <= std::numeric_limits::max() / 100) { - n = q; - s += 2; - } else { - break; - } + if (q > std::numeric_limits::max() / 100) break; + n = q; + s += 2; } auto q = rotr(n * mod_inv_5, 1); if (q <= std::numeric_limits::max() / 10) {