From 3a044814857ea3a2734abc0df815b13731baa10a Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 11 Sep 2021 17:54:40 -0700 Subject: [PATCH] Remove data::hex_digits --- include/fmt/format-inl.h | 7 ++----- include/fmt/format.h | 5 ++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 751d7ba4..4324c483 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -154,7 +154,6 @@ static constexpr uint64_t log10_2_significand = 0x4d104d427de7fbcc; #if __cplusplus < 201703L template constexpr const char basic_data::digits[][2]; -template constexpr const char basic_data::hex_digits[]; template constexpr const unsigned basic_data::prefixes[]; #endif @@ -916,8 +915,7 @@ inline uint64_t umul96_lower64(uint32_t x, uint64_t y) FMT_NOEXCEPT { inline int floor_log10_pow2(int e) FMT_NOEXCEPT { FMT_ASSERT(e <= 1700 && e >= -1700, "too large exponent"); const int shift = 22; - return (e * static_cast(log10_2_significand >> (64 - shift))) >> - shift; + return (e * static_cast(log10_2_significand >> (64 - shift))) >> shift; } // Various fast log computations. @@ -935,8 +933,7 @@ inline int floor_log10_pow2_minus_log10_4_over_3(int e) FMT_NOEXCEPT { FMT_ASSERT(e <= 1700 && e >= -1700, "too large exponent"); const uint64_t log10_4_over_3_fractional_digits = 0x1ffbfc2bbc780375; const int shift_amount = 22; - return (e * static_cast(log10_2_significand >> - (64 - shift_amount)) - + return (e * static_cast(log10_2_significand >> (64 - shift_amount)) - static_cast(log10_4_over_3_fractional_digits >> (64 - shift_amount))) >> shift_amount; diff --git a/include/fmt/format.h b/include/fmt/format.h index 1ef8587e..c794f8a4 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -905,7 +905,6 @@ template struct basic_data { {'9', '0'}, {'9', '1'}, {'9', '2'}, {'9', '3'}, {'9', '4'}, {'9', '5'}, {'9', '6'}, {'9', '7'}, {'9', '8'}, {'9', '9'}}; - FMT_API static constexpr const char hex_digits[] = "0123456789abcdef"; FMT_API static constexpr const unsigned prefixes[4] = {0, 0, 0x1000000u | '+', 0x1000000u | ' '}; }; @@ -1135,7 +1134,7 @@ FMT_CONSTEXPR auto format_uint(Char* buffer, UInt value, int num_digits, buffer += num_digits; Char* end = buffer; do { - const char* digits = upper ? "0123456789ABCDEF" : data::hex_digits; + const char* digits = upper ? "0123456789ABCDEF" : "0123456789abcdef"; unsigned digit = (value & ((1 << BASE_BITS) - 1)); *--buffer = static_cast(BASE_BITS < 4 ? static_cast('0' + digit) : digits[digit]); @@ -1158,7 +1157,7 @@ auto format_uint(Char* buffer, detail::fallback_uintptr n, int num_digits, auto p = buffer; for (int i = 0; i < char_digits; ++i) { unsigned digit = (value & ((1 << BASE_BITS) - 1)); - *--p = static_cast(data::hex_digits[digit]); + *--p = static_cast("0123456789abcdef"[digit]); value >>= BASE_BITS; } }