From 085171e7e65412c59df3ad7a124dd3701e1baffb Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 22 Sep 2020 19:36:52 -0700 Subject: [PATCH] Remove grisu_count_digits --- include/fmt/format-inl.h | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 925dbc4a..76bd34aa 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -1498,20 +1498,6 @@ enum result { }; } -// A version of count_digits optimized for grisu_gen_digits. -inline int grisu_count_digits(uint32_t n) { - if (n < 10) return 1; - if (n < 100) return 2; - if (n < 1000) return 3; - if (n < 10000) return 4; - if (n < 100000) return 5; - if (n < 1000000) return 6; - if (n < 10000000) return 7; - if (n < 100000000) return 8; - if (n < 1000000000) return 9; - return 10; -} - // Generates output using the Grisu digit-gen algorithm. // error: the size of the region (lower, upper) outside of which numbers // definitely do not round to value (Delta in Grisu3). @@ -1527,7 +1513,7 @@ FMT_ALWAYS_INLINE digits::result grisu_gen_digits(fp value, uint64_t error, FMT_ASSERT(integral == value.f >> -one.e, ""); // The fractional part of scaled value (p2 in Grisu) c = value % one. uint64_t fractional = value.f & (one.f - 1); - exp = grisu_count_digits(integral); // kappa in Grisu. + exp = count_digits(integral); // kappa in Grisu. // Divide by 10 to prevent overflow. auto result = handler.on_start(data::powers_of_10_64[exp - 1] << -one.e, value.f / 10, error * 10, exp);