From 578874033aeb12320f0d27eaa4f7bd02ce3aa4ee Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 25 Feb 2021 05:58:58 -0800 Subject: [PATCH] Revert "Optimize handling of integer constants" (#2147) This reverts commit 2797588be121c79915d374788ce530ad642a98cd. --- include/fmt/format-inl.h | 8 +++++++- include/fmt/format.h | 8 +------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 2bc5a9ac..be1ddf40 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -244,6 +244,11 @@ const typename basic_data::digit_pair basic_data::digits[] = { {'9', '0'}, {'9', '1'}, {'9', '2'}, {'9', '3'}, {'9', '4'}, {'9', '5'}, {'9', '6'}, {'9', '7'}, {'9', '8'}, {'9', '9'}}; +#define FMT_POWERS_OF_10(factor) \ + factor * 10, (factor)*100, (factor)*1000, (factor)*10000, (factor)*100000, \ + (factor)*1000000, (factor)*10000000, (factor)*100000000, \ + (factor)*1000000000 + template const uint64_t basic_data::powers_of_10_64[] = { 1, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(1000000000ULL), @@ -258,7 +263,8 @@ const uint64_t basic_data::zero_or_powers_of_10_64[] = { 10000000000000000000ULL}; template -constexpr uint32_t basic_data::zero_or_powers_of_10_32_new[]; +const uint32_t basic_data::zero_or_powers_of_10_32_new[] = { + 0, 0, FMT_POWERS_OF_10(1)}; template const uint64_t basic_data::zero_or_powers_of_10_64_new[] = { diff --git a/include/fmt/format.h b/include/fmt/format.h index 8eb4bcce..44c2a3b4 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1023,16 +1023,10 @@ template struct FMT_EXTERN_TEMPLATE_API divtest_table_entry { T max_quotient; }; -#define FMT_POWERS_OF_10(factor) \ - factor * 10u, (factor)*100u, (factor)*1000u, (factor)*10000u, \ - (factor)*100000u, (factor)*1000000u, (factor)*10000000u, \ - (factor)*100000000u, (factor)*1000000000u - // Static data is placed in this class template for the header-only config. template struct FMT_EXTERN_TEMPLATE_API basic_data { static const uint64_t powers_of_10_64[]; - static constexpr uint32_t zero_or_powers_of_10_32_new[] = { - 0, 0, FMT_POWERS_OF_10(1)}; + static const uint32_t zero_or_powers_of_10_32_new[]; static const uint64_t zero_or_powers_of_10_64_new[]; static const uint64_t grisu_pow10_significands[]; static const int16_t grisu_pow10_exponents[];