[clang-tidy] Use auto
Found with hicpp-use-auto Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
bb0c8bfea8
commit
12f9437e22
@ -800,7 +800,7 @@ FMT_ALWAYS_INLINE digits::result grisu_gen_digits(fp value, uint64_t error,
|
|||||||
// The integral part of scaled value (p1 in Grisu) = value / one. It cannot be
|
// The integral part of scaled value (p1 in Grisu) = value / one. It cannot be
|
||||||
// zero because it contains a product of two 64-bit numbers with MSB set (due
|
// zero because it contains a product of two 64-bit numbers with MSB set (due
|
||||||
// to normalization) - 1, shifted right by at most 60 bits.
|
// to normalization) - 1, shifted right by at most 60 bits.
|
||||||
uint32_t integral = static_cast<uint32_t>(value.f >> -one.e);
|
auto integral = static_cast<uint32_t>(value.f >> -one.e);
|
||||||
FMT_ASSERT(integral != 0, "");
|
FMT_ASSERT(integral != 0, "");
|
||||||
FMT_ASSERT(integral == value.f >> -one.e, "");
|
FMT_ASSERT(integral == value.f >> -one.e, "");
|
||||||
// The fractional part of scaled value (p2 in Grisu) c = value % one.
|
// The fractional part of scaled value (p2 in Grisu) c = value % one.
|
||||||
|
@ -862,7 +862,7 @@ inline Char* format_decimal(Char* buffer, UInt value, int num_digits,
|
|||||||
// Integer division is slow so do it for a group of two digits instead
|
// Integer division is slow so do it for a group of two digits instead
|
||||||
// of for every digit. The idea comes from the talk by Alexandrescu
|
// of for every digit. The idea comes from the talk by Alexandrescu
|
||||||
// "Three Optimization Tips for C++". See speed-test for a comparison.
|
// "Three Optimization Tips for C++". See speed-test for a comparison.
|
||||||
unsigned index = static_cast<unsigned>((value % 100) * 2);
|
auto index = static_cast<unsigned>((value % 100) * 2);
|
||||||
value /= 100;
|
value /= 100;
|
||||||
*--buffer = static_cast<Char>(data::digits[index + 1]);
|
*--buffer = static_cast<Char>(data::digits[index + 1]);
|
||||||
add_thousands_sep(buffer);
|
add_thousands_sep(buffer);
|
||||||
@ -873,7 +873,7 @@ inline Char* format_decimal(Char* buffer, UInt value, int num_digits,
|
|||||||
*--buffer = static_cast<Char>('0' + value);
|
*--buffer = static_cast<Char>('0' + value);
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
unsigned index = static_cast<unsigned>(value * 2);
|
auto index = static_cast<unsigned>(value * 2);
|
||||||
*--buffer = static_cast<Char>(data::digits[index + 1]);
|
*--buffer = static_cast<Char>(data::digits[index + 1]);
|
||||||
add_thousands_sep(buffer);
|
add_thousands_sep(buffer);
|
||||||
*--buffer = static_cast<Char>(data::digits[index]);
|
*--buffer = static_cast<Char>(data::digits[index]);
|
||||||
@ -1568,7 +1568,7 @@ template <typename Range> class basic_writer {
|
|||||||
void on_num() {
|
void on_num() {
|
||||||
std::string groups = internal::grouping<char_type>(writer.locale_);
|
std::string groups = internal::grouping<char_type>(writer.locale_);
|
||||||
if (groups.empty()) return on_dec();
|
if (groups.empty()) return on_dec();
|
||||||
char_type sep = internal::thousands_sep<char_type>(writer.locale_);
|
auto sep = internal::thousands_sep<char_type>(writer.locale_);
|
||||||
if (!sep) return on_dec();
|
if (!sep) return on_dec();
|
||||||
int num_digits = internal::count_digits(abs_value);
|
int num_digits = internal::count_digits(abs_value);
|
||||||
int size = num_digits;
|
int size = num_digits;
|
||||||
@ -2965,7 +2965,7 @@ class format_int {
|
|||||||
// Integer division is slow so do it for a group of two digits instead
|
// Integer division is slow so do it for a group of two digits instead
|
||||||
// of for every digit. The idea comes from the talk by Alexandrescu
|
// of for every digit. The idea comes from the talk by Alexandrescu
|
||||||
// "Three Optimization Tips for C++". See speed-test for a comparison.
|
// "Three Optimization Tips for C++". See speed-test for a comparison.
|
||||||
unsigned index = static_cast<unsigned>((value % 100) * 2);
|
auto index = static_cast<unsigned>((value % 100) * 2);
|
||||||
value /= 100;
|
value /= 100;
|
||||||
*--ptr = internal::data::digits[index + 1];
|
*--ptr = internal::data::digits[index + 1];
|
||||||
*--ptr = internal::data::digits[index];
|
*--ptr = internal::data::digits[index];
|
||||||
@ -2974,14 +2974,14 @@ class format_int {
|
|||||||
*--ptr = static_cast<char>('0' + value);
|
*--ptr = static_cast<char>('0' + value);
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
unsigned index = static_cast<unsigned>(value * 2);
|
auto index = static_cast<unsigned>(value * 2);
|
||||||
*--ptr = internal::data::digits[index + 1];
|
*--ptr = internal::data::digits[index + 1];
|
||||||
*--ptr = internal::data::digits[index];
|
*--ptr = internal::data::digits[index];
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void format_signed(long long value) {
|
void format_signed(long long value) {
|
||||||
unsigned long long abs_value = static_cast<unsigned long long>(value);
|
auto abs_value = static_cast<unsigned long long>(value);
|
||||||
bool negative = value < 0;
|
bool negative = value < 0;
|
||||||
if (negative) abs_value = 0 - abs_value;
|
if (negative) abs_value = 0 - abs_value;
|
||||||
str_ = format_decimal(abs_value);
|
str_ = format_decimal(abs_value);
|
||||||
|
Loading…
Reference in New Issue
Block a user