From 5e4f24279603b2fc98f6464302221842053c5183 Mon Sep 17 00:00:00 2001 From: Andreas Tsouchlos Date: Tue, 15 Feb 2022 09:47:28 +0100 Subject: [PATCH] Renamed functions dedicated to decimal to better reflect their function --- const_fmt/format_impl.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/const_fmt/format_impl.h b/const_fmt/format_impl.h index fdbb6bd..26a6f1a 100644 --- a/const_fmt/format_impl.h +++ b/const_fmt/format_impl.h @@ -32,7 +32,7 @@ namespace const_fmt { namespace const_fmt_detail { (factor)*1000000000 template -constexpr int count_digits_fallback(T n) { +constexpr int count_digits_decimal_fallback(T n) { int count = 1; for (;;) { if (n < 10) return count; @@ -44,7 +44,7 @@ constexpr int count_digits_fallback(T n) { } } -inline int do_count_digits(uint64_t n) { +inline int do_count_digits_decimal(uint64_t n) { // Maps bsr(n) to ceil(log10(pow(2, bsr(n) + 1) - 1)). static constexpr uint8_t bsr2log10[] = { 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, @@ -71,10 +71,10 @@ constexpr inline auto count_digits_base(uint64_t n) -> int { return result; } else { if (!std::is_constant_evaluated()) { - return do_count_digits(n); + return do_count_digits_decimal(n); } - return count_digits_fallback(n); + return count_digits_decimal_fallback(n); } } @@ -135,6 +135,7 @@ constexpr inline void format_base(char* out, uint_t value, int n_digits, copy2(out, digits2_base(static_cast(value))); } + // returns {abs_value, was_negative} template constexpr std::pair::type, bool> @@ -165,7 +166,8 @@ constexpr std::pair get_abs_value(int_t value) { template constexpr inline void format_int(char* out, uint_t value) { // format_decimal(out, value, count_digits(value), t_fmt_node.length); - format_base(out, value, count_digits_base(value), + format_base(out, value, + count_digits_base(value), t_fmt_node.length); }