From ca9c83f824270a7ee1d183f29faa01262f810fd6 Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 4 Apr 2020 20:06:04 +0300 Subject: [PATCH] Minor improvment to number padding --- include/spdlog/details/fmt_helper.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/include/spdlog/details/fmt_helper.h b/include/spdlog/details/fmt_helper.h index 183690d2..a528bceb 100644 --- a/include/spdlog/details/fmt_helper.h +++ b/include/spdlog/details/fmt_helper.h @@ -63,11 +63,9 @@ template inline void pad_uint(T n, unsigned int width, memory_buf_t &dest) { static_assert(std::is_unsigned::value, "pad_uint must get unsigned T"); - auto digits = count_digits(n); - if (width > digits) + for(auto digits = count_digits(n); digits < width; digits++) { - const char *zeroes = "0000000000000000000"; - dest.append(zeroes, zeroes + width - digits); + dest.push_back('0'); } append_int(n, dest); }