Commit d8fd1699 authored by Victor Zverovich's avatar Victor Zverovich

Make data names follow naming conventions

parent c286ffc8
......@@ -358,7 +358,7 @@ template <typename Char> struct ansi_color_escape {
// If we have a terminal color, we need to output another escape code
// sequence.
if (!text_color.is_rgb) {
bool is_background = esc == internal::data::BACKGROUND_COLOR;
bool is_background = esc == internal::data::background_color;
uint32_t value = text_color.value.term_color;
// Background ASCII codes are the same as the foreground ones but with
// 10 more.
......@@ -430,13 +430,13 @@ template <typename Char> struct ansi_color_escape {
template <typename Char>
FMT_CONSTEXPR ansi_color_escape<Char> make_foreground_color(
internal::color_type foreground) FMT_NOEXCEPT {
return ansi_color_escape<Char>(foreground, internal::data::FOREGROUND_COLOR);
return ansi_color_escape<Char>(foreground, internal::data::foreground_color);
}
template <typename Char>
FMT_CONSTEXPR ansi_color_escape<Char> make_background_color(
internal::color_type background) FMT_NOEXCEPT {
return ansi_color_escape<Char>(background, internal::data::BACKGROUND_COLOR);
return ansi_color_escape<Char>(background, internal::data::background_color);
}
template <typename Char>
......@@ -455,17 +455,17 @@ inline void fputs<wchar_t>(const wchar_t* chars, FILE* stream) FMT_NOEXCEPT {
}
template <typename Char> inline void reset_color(FILE* stream) FMT_NOEXCEPT {
fputs(internal::data::RESET_COLOR, stream);
fputs(internal::data::reset_color, stream);
}
template <> inline void reset_color<wchar_t>(FILE* stream) FMT_NOEXCEPT {
fputs(internal::data::WRESET_COLOR, stream);
fputs(internal::data::wreset_color, stream);
}
template <typename Char>
inline void reset_color(basic_memory_buffer<Char>& buffer) FMT_NOEXCEPT {
const char* begin = data::RESET_COLOR;
const char* end = begin + sizeof(data::RESET_COLOR) - 1;
const char* begin = data::reset_color;
const char* end = begin + sizeof(data::reset_color) - 1;
buffer.append(begin, end);
}
......
......@@ -255,7 +255,7 @@ int format_float(char* buf, std::size_t size, const char* format, int precision,
}
template <typename T>
const char basic_data<T>::DIGITS[] =
const char basic_data<T>::digits[] =
"0001020304050607080910111213141516171819"
"2021222324252627282930313233343536373839"
"4041424344454647484950515253545556575859"
......@@ -263,7 +263,7 @@ const char basic_data<T>::DIGITS[] =
"8081828384858687888990919293949596979899";
template <typename T>
const char basic_data<T>::HEX_DIGITS[] = "0123456789abcdef";
const char basic_data<T>::hex_digits[] = "0123456789abcdef";
#define FMT_POWERS_OF_10(factor) \
factor * 10, factor * 100, factor * 1000, factor * 10000, factor * 100000, \
......@@ -271,23 +271,23 @@ const char basic_data<T>::HEX_DIGITS[] = "0123456789abcdef";
factor * 1000000000
template <typename T>
const uint64_t basic_data<T>::POWERS_OF_10_64[] = {
const uint64_t basic_data<T>::powers_of_10_64[] = {
1, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(1000000000ull),
10000000000000000000ull};
template <typename T>
const uint32_t basic_data<T>::ZERO_OR_POWERS_OF_10_32[] = {0,
const uint32_t basic_data<T>::zero_or_powers_of_10_32[] = {0,
FMT_POWERS_OF_10(1)};
template <typename T>
const uint64_t basic_data<T>::ZERO_OR_POWERS_OF_10_64[] = {
const uint64_t basic_data<T>::zero_or_powers_of_10_64[] = {
0, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(1000000000ull),
10000000000000000000ull};
// Normalized 64-bit significands of pow(10, k), for k = -348, -340, ..., 340.
// These are generated by support/compute-powers.py.
template <typename T>
const uint64_t basic_data<T>::POW10_SIGNIFICANDS[] = {
const uint64_t basic_data<T>::pow10_significands[] = {
0xfa8fd5a0081c0288, 0xbaaee17fa23ebf76, 0x8b16fb203055ac76,
0xcf42894a5dce35ea, 0x9a6bb0aa55653b2d, 0xe61acf033d1a45df,
0xab70fe17c79ac6ca, 0xff77b1fcbebcdc4f, 0xbe5691ef416bd60c,
......@@ -322,7 +322,7 @@ const uint64_t basic_data<T>::POW10_SIGNIFICANDS[] = {
// Binary exponents of pow(10, k), for k = -348, -340, ..., 340, corresponding
// to significands above.
template <typename T>
const int16_t basic_data<T>::POW10_EXPONENTS[] = {
const int16_t basic_data<T>::pow10_exponents[] = {
-1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007, -980, -954,
-927, -901, -874, -847, -821, -794, -768, -741, -715, -688, -661,
-635, -608, -582, -555, -529, -502, -475, -449, -422, -396, -369,
......@@ -333,11 +333,11 @@ const int16_t basic_data<T>::POW10_EXPONENTS[] = {
827, 853, 880, 907, 933, 960, 986, 1013, 1039, 1066};
template <typename T>
const char basic_data<T>::FOREGROUND_COLOR[] = "\x1b[38;2;";
const char basic_data<T>::foreground_color[] = "\x1b[38;2;";
template <typename T>
const char basic_data<T>::BACKGROUND_COLOR[] = "\x1b[48;2;";
template <typename T> const char basic_data<T>::RESET_COLOR[] = "\x1b[0m";
template <typename T> const wchar_t basic_data<T>::WRESET_COLOR[] = L"\x1b[0m";
const char basic_data<T>::background_color[] = "\x1b[48;2;";
template <typename T> const char basic_data<T>::reset_color[] = "\x1b[0m";
template <typename T> const wchar_t basic_data<T>::wreset_color[] = L"\x1b[0m";
template <typename T> struct bits {
static FMT_CONSTEXPR_DECL const int value =
......@@ -455,7 +455,7 @@ FMT_FUNC fp get_cached_power(int min_exponent, int& pow10_exponent) {
const int dec_exp_step = 8;
index = (index - first_dec_exp - 1) / dec_exp_step + 1;
pow10_exponent = first_dec_exp + index * dec_exp_step;
return fp(data::POW10_SIGNIFICANDS[index], data::POW10_EXPONENTS[index]);
return fp(data::pow10_significands[index], data::pow10_exponents[index]);
}
enum round_direction { unknown, up, down };
......@@ -505,7 +505,7 @@ digits::result grisu_gen_digits(fp value, uint64_t error, int& exp,
uint64_t fractional = value.f & (one.f - 1);
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,
auto result = handler.on_start(data::powers_of_10_64[exp - 1] << -one.e,
value.f / 10, error * 10, exp);
if (result != digits::more) return result;
// Generate digits for the integral part. This can produce up to 10 digits.
......@@ -561,7 +561,7 @@ digits::result grisu_gen_digits(fp value, uint64_t error, int& exp,
uint64_t remainder =
(static_cast<uint64_t>(integral) << -one.e) + fractional;
result = handler.on_digit(static_cast<char>('0' + digit),
data::POWERS_OF_10_64[exp] << -one.e, remainder,
data::powers_of_10_64[exp] << -one.e, remainder,
error, exp, true);
if (result != digits::more) return result;
} while (exp > 0);
......@@ -658,11 +658,11 @@ template <int GRISU_VERSION> struct grisu_shortest_handler {
buf[size++] = digit;
if (remainder >= error) return digits::more;
if (GRISU_VERSION != 3) {
uint64_t d = integral ? diff : diff * data::POWERS_OF_10_64[-exp];
uint64_t d = integral ? diff : diff * data::powers_of_10_64[-exp];
round(d, divisor, remainder, error);
return digits::done;
}
uint64_t unit = integral ? 1 : data::POWERS_OF_10_64[-exp];
uint64_t unit = integral ? 1 : data::powers_of_10_64[-exp];
uint64_t up = (diff - 1) * unit; // wp_Wup
round(up, divisor, remainder, error);
uint64_t down = (diff + 1) * unit; // wp_Wdown
......
......@@ -614,17 +614,17 @@ using uint32_or_64_t =
// 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 uint64_t POWERS_OF_10_64[];
static const uint32_t ZERO_OR_POWERS_OF_10_32[];
static const uint64_t ZERO_OR_POWERS_OF_10_64[];
static const uint64_t POW10_SIGNIFICANDS[];
static const int16_t POW10_EXPONENTS[];
static const char DIGITS[];
static const char HEX_DIGITS[];
static const char FOREGROUND_COLOR[];
static const char BACKGROUND_COLOR[];
static const char RESET_COLOR[5];
static const wchar_t WRESET_COLOR[5];
static const uint64_t powers_of_10_64[];
static const uint32_t zero_or_powers_of_10_32[];
static const uint64_t zero_or_powers_of_10_64[];
static const uint64_t pow10_significands[];
static const int16_t pow10_exponents[];
static const char digits[];
static const char hex_digits[];
static const char foreground_color[];
static const char background_color[];
static const char reset_color[5];
static const wchar_t wreset_color[5];
};
FMT_EXTERN template struct basic_data<void>;
......@@ -639,7 +639,7 @@ inline int count_digits(uint64_t n) {
// Based on http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
// and the benchmark https://github.com/localvoid/cxx-benchmark-count-digits.
int t = (64 - FMT_BUILTIN_CLZLL(n | 1)) * 1233 >> 12;
return t - (n < data::ZERO_OR_POWERS_OF_10_64[t]) + 1;
return t - (n < data::zero_or_powers_of_10_64[t]) + 1;
}
#else
// Fallback version of count_digits used when __builtin_clz is not available.
......@@ -700,7 +700,7 @@ class decimal_formatter {
char* buffer_;
void write_pair(unsigned N, uint32_t index) {
std::memcpy(buffer_ + N, data::DIGITS + index * 2, 2);
std::memcpy(buffer_ + N, data::digits + index * 2, 2);
}
public:
......@@ -717,7 +717,7 @@ class decimal_formatter {
unsigned n = N - 1;
unsigned a = n / 5 * n * 53 / 16;
uint64_t t =
((1ULL << (32 + a)) / data::ZERO_OR_POWERS_OF_10_32[n] + 1 - n / 9);
((1ULL << (32 + a)) / data::zero_or_powers_of_10_32[n] + 1 - n / 9);
t = ((t * u) >> a) + n / 5 * 4;
write_pair(0, t >> 32);
for (unsigned i = 2; i < N; i += 2) {
......@@ -737,7 +737,7 @@ class decimal_formatter {
// Optional version of count_digits for better performance on 32-bit platforms.
inline int count_digits(uint32_t n) {
int t = (32 - FMT_BUILTIN_CLZ(n | 1)) * 1233 >> 12;
return t - (n < data::ZERO_OR_POWERS_OF_10_32[t]) + 1;
return t - (n < data::zero_or_powers_of_10_32[t]) + 1;
}
#endif
......@@ -766,9 +766,9 @@ inline Char* format_decimal(Char* buffer, UInt value, int num_digits,
// "Three Optimization Tips for C++". See speed-test for a comparison.
unsigned index = static_cast<unsigned>((value % 100) * 2);
value /= 100;
*--buffer = static_cast<Char>(data::DIGITS[index + 1]);
*--buffer = static_cast<Char>(data::digits[index + 1]);
thousands_sep(buffer);
*--buffer = static_cast<Char>(data::DIGITS[index]);
*--buffer = static_cast<Char>(data::digits[index]);
thousands_sep(buffer);
}
if (value < 10) {
......@@ -776,9 +776,9 @@ inline Char* format_decimal(Char* buffer, UInt value, int num_digits,
return end;
}
unsigned index = static_cast<unsigned>(value * 2);
*--buffer = static_cast<Char>(data::DIGITS[index + 1]);
*--buffer = static_cast<Char>(data::digits[index + 1]);
thousands_sep(buffer);
*--buffer = static_cast<Char>(data::DIGITS[index]);
*--buffer = static_cast<Char>(data::digits[index]);
return end;
}
......@@ -805,7 +805,7 @@ inline Char* 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" : data::hex_digits;
unsigned digit = (value & ((1 << BASE_BITS) - 1));
*--buffer = static_cast<Char>(BASE_BITS < 4 ? static_cast<char>('0' + digit)
: digits[digit]);
......@@ -828,7 +828,7 @@ Char* format_uint(Char* buffer, internal::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<Char>(data::HEX_DIGITS[digit]);
*--p = static_cast<Char>(data::hex_digits[digit]);
value >>= BASE_BITS;
}
}
......@@ -972,11 +972,11 @@ template <typename Char, typename It> It write_exponent(int exp, It it) {
if (exp >= 100) {
*it++ = static_cast<Char>(static_cast<char>('0' + exp / 100));
exp %= 100;
const char* d = data::DIGITS + exp * 2;
const char* d = data::digits + exp * 2;
*it++ = static_cast<Char>(d[0]);
*it++ = static_cast<Char>(d[1]);
} else {
const char* d = data::DIGITS + exp * 2;
const char* d = data::digits + exp * 2;
*it++ = static_cast<Char>(d[0]);
*it++ = static_cast<Char>(d[1]);
}
......@@ -2813,16 +2813,16 @@ class format_int {
// "Three Optimization Tips for C++". See speed-test for a comparison.
unsigned index = static_cast<unsigned>((value % 100) * 2);
value /= 100;
*--ptr = internal::data::DIGITS[index + 1];
*--ptr = internal::data::DIGITS[index];
*--ptr = internal::data::digits[index + 1];
*--ptr = internal::data::digits[index];
}
if (value < 10) {
*--ptr = static_cast<char>('0' + value);
return ptr;
}
unsigned index = static_cast<unsigned>(value * 2);
*--ptr = internal::data::DIGITS[index + 1];
*--ptr = internal::data::DIGITS[index];
*--ptr = internal::data::digits[index + 1];
*--ptr = internal::data::digits[index];
return ptr;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment