Minor improvment to number padding

This commit is contained in:
gabime 2020-04-04 20:06:04 +03:00
parent fc900e2432
commit ca9c83f824

View File

@ -63,11 +63,9 @@ template<typename T>
inline void pad_uint(T n, unsigned int width, memory_buf_t &dest) inline void pad_uint(T n, unsigned int width, memory_buf_t &dest)
{ {
static_assert(std::is_unsigned<T>::value, "pad_uint must get unsigned T"); static_assert(std::is_unsigned<T>::value, "pad_uint must get unsigned T");
auto digits = count_digits(n); for(auto digits = count_digits(n); digits < width; digits++)
if (width > digits)
{ {
const char *zeroes = "0000000000000000000"; dest.push_back('0');
dest.append(zeroes, zeroes + width - digits);
} }
append_int(n, dest); append_int(n, dest);
} }