mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-02 11:28:20 +00:00
Optimize format_uint
This commit is contained in:
parent
7446818f98
commit
9755307842
@ -1112,6 +1112,10 @@ Char* format_uint(Char* buffer, detail::fallback_uintptr n, int num_digits,
|
||||
|
||||
template <unsigned BASE_BITS, typename Char, typename It, typename UInt>
|
||||
inline It format_uint(It out, UInt value, int num_digits, bool upper = false) {
|
||||
if (auto ptr = to_pointer<Char>(out, num_digits)) {
|
||||
format_uint<BASE_BITS>(ptr, value, num_digits, upper);
|
||||
return out;
|
||||
}
|
||||
// Buffer should be large enough to hold all digits (digits / BASE_BITS + 1).
|
||||
char buffer[num_bits<UInt>() / BASE_BITS + 1];
|
||||
format_uint<BASE_BITS>(buffer, value, num_digits, upper);
|
||||
|
Loading…
Reference in New Issue
Block a user