From 6f3536f97442f041e1454a8ab1f700dc0abd4c97 Mon Sep 17 00:00:00 2001 From: jk-jeon <33922675+jk-jeon@users.noreply.github.com> Date: Tue, 29 Sep 2020 06:24:53 -0700 Subject: [PATCH] Move zero-check to an earlier branch (#1906) --- include/fmt/format-inl.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 7ffda020..e4039e52 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -2258,6 +2258,9 @@ FMT_SAFEBUFFERS decimal_fp to_decimal(T x) FMT_NOEXCEPT { (static_cast(1) << float_info::significand_bits); } else { // Subnormal case; the interval is always regular. + if (significand == 0) { + return decimal_fp{0, 0}; + } exponent = float_info::min_exponent - float_info::significand_bits; } @@ -2307,10 +2310,6 @@ FMT_SAFEBUFFERS decimal_fp to_decimal(T x) FMT_NOEXCEPT { goto small_divisor_case_label; } } - if (ret_value.significand == 0) { - ret_value.exponent = 0; - return ret_value; - } ret_value.exponent = minus_k + float_info::kappa + 1; // We may need to remove trailing zeros