mirror of
https://github.com/shadps4-emu/ext-fmt.git
synced 2024-11-23 09:49:42 +00:00
Move more data out of basic_data
This commit is contained in:
parent
128f007b25
commit
54d3b1710e
File diff suppressed because it is too large
Load Diff
@ -945,29 +945,55 @@ struct FMT_EXTERN_TEMPLATE_API uint128_wrapper {
|
||||
#endif
|
||||
};
|
||||
|
||||
#define FMT_POWERS_OF_10(factor) \
|
||||
factor * 10, (factor)*100, (factor)*1000, (factor)*10000, (factor)*100000, \
|
||||
(factor)*1000000, (factor)*10000000, (factor)*100000000, \
|
||||
(factor)*1000000000
|
||||
|
||||
// Static data is placed in this class template for the header-only config.
|
||||
template <typename T = void> struct FMT_EXTERN_TEMPLATE_API basic_data {
|
||||
static const uint32_t zero_or_powers_of_10_32[];
|
||||
static const uint64_t zero_or_powers_of_10_64[];
|
||||
static const uint64_t dragonbox_pow10_significands_64[];
|
||||
static const uint128_wrapper dragonbox_pow10_significands_128[];
|
||||
static constexpr const uint32_t zero_or_powers_of_10_32[] = {
|
||||
0, 0, FMT_POWERS_OF_10(1U)};
|
||||
|
||||
static constexpr const uint64_t zero_or_powers_of_10_64[] = {
|
||||
0, 0, FMT_POWERS_OF_10(1U), FMT_POWERS_OF_10(1000000000ULL),
|
||||
10000000000000000000ULL};
|
||||
|
||||
// log10(2) = 0x0.4d104d427de7fbcc...
|
||||
static const uint64_t log10_2_significand = 0x4d104d427de7fbcc;
|
||||
#if !FMT_USE_FULL_CACHE_DRAGONBOX
|
||||
static const uint64_t powers_of_5_64[];
|
||||
static const uint32_t dragonbox_pow10_recovery_errors[];
|
||||
#endif
|
||||
|
||||
// GCC generates slightly better code for pairs than chars.
|
||||
using digit_pair = char[2];
|
||||
static const digit_pair digits[];
|
||||
static constexpr const digit_pair digits[] = {
|
||||
{'0', '0'}, {'0', '1'}, {'0', '2'}, {'0', '3'}, {'0', '4'}, {'0', '5'},
|
||||
{'0', '6'}, {'0', '7'}, {'0', '8'}, {'0', '9'}, {'1', '0'}, {'1', '1'},
|
||||
{'1', '2'}, {'1', '3'}, {'1', '4'}, {'1', '5'}, {'1', '6'}, {'1', '7'},
|
||||
{'1', '8'}, {'1', '9'}, {'2', '0'}, {'2', '1'}, {'2', '2'}, {'2', '3'},
|
||||
{'2', '4'}, {'2', '5'}, {'2', '6'}, {'2', '7'}, {'2', '8'}, {'2', '9'},
|
||||
{'3', '0'}, {'3', '1'}, {'3', '2'}, {'3', '3'}, {'3', '4'}, {'3', '5'},
|
||||
{'3', '6'}, {'3', '7'}, {'3', '8'}, {'3', '9'}, {'4', '0'}, {'4', '1'},
|
||||
{'4', '2'}, {'4', '3'}, {'4', '4'}, {'4', '5'}, {'4', '6'}, {'4', '7'},
|
||||
{'4', '8'}, {'4', '9'}, {'5', '0'}, {'5', '1'}, {'5', '2'}, {'5', '3'},
|
||||
{'5', '4'}, {'5', '5'}, {'5', '6'}, {'5', '7'}, {'5', '8'}, {'5', '9'},
|
||||
{'6', '0'}, {'6', '1'}, {'6', '2'}, {'6', '3'}, {'6', '4'}, {'6', '5'},
|
||||
{'6', '6'}, {'6', '7'}, {'6', '8'}, {'6', '9'}, {'7', '0'}, {'7', '1'},
|
||||
{'7', '2'}, {'7', '3'}, {'7', '4'}, {'7', '5'}, {'7', '6'}, {'7', '7'},
|
||||
{'7', '8'}, {'7', '9'}, {'8', '0'}, {'8', '1'}, {'8', '2'}, {'8', '3'},
|
||||
{'8', '4'}, {'8', '5'}, {'8', '6'}, {'8', '7'}, {'8', '8'}, {'8', '9'},
|
||||
{'9', '0'}, {'9', '1'}, {'9', '2'}, {'9', '3'}, {'9', '4'}, {'9', '5'},
|
||||
{'9', '6'}, {'9', '7'}, {'9', '8'}, {'9', '9'}};
|
||||
|
||||
static constexpr const char hex_digits[] = "0123456789abcdef";
|
||||
static const char signs[];
|
||||
static constexpr const char signs[] = {0, '-', '+', ' '};
|
||||
static constexpr const unsigned prefixes[4] = {0, 0, 0x1000000u | '+',
|
||||
0x1000000u | ' '};
|
||||
static constexpr const char left_padding_shifts[] = {31, 31, 0, 1, 0};
|
||||
static constexpr const char right_padding_shifts[] = {0, 31, 0, 1, 0};
|
||||
};
|
||||
|
||||
// This is a struct rather than an alias to avoid shadowing warnings in gcc.
|
||||
struct data : basic_data<> {};
|
||||
|
||||
// Maps bsr(n) to ceil(log10(pow(2, bsr(n) + 1) - 1)).
|
||||
// This is a function instead of an array to workaround a bug in GCC10 (#1810).
|
||||
FMT_INLINE uint16_t bsr2log10(int bsr) {
|
||||
@ -983,9 +1009,6 @@ FMT_INLINE uint16_t bsr2log10(int bsr) {
|
||||
FMT_EXTERN template struct FMT_INSTANTIATION_DECL_API basic_data<void>;
|
||||
#endif
|
||||
|
||||
// This is a struct rather than an alias to avoid shadowing warnings in gcc.
|
||||
struct data : basic_data<> {};
|
||||
|
||||
template <typename T> FMT_CONSTEXPR int count_digits_fallback(T n) {
|
||||
int count = 1;
|
||||
for (;;) {
|
||||
|
Loading…
Reference in New Issue
Block a user