From 76389e057fca1ea158d79785f668808a088d5d3a Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 11 Apr 2020 19:50:19 +0300 Subject: [PATCH] Optimize fmt_helper::pad3() --- include/spdlog/details/fmt_helper.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/include/spdlog/details/fmt_helper.h b/include/spdlog/details/fmt_helper.h index 01c62f3b..81181c6c 100644 --- a/include/spdlog/details/fmt_helper.h +++ b/include/spdlog/details/fmt_helper.h @@ -73,9 +73,21 @@ inline void pad_uint(T n, unsigned int width, memory_buf_t &dest) template inline void pad3(T n, memory_buf_t &dest) { - pad_uint(n, 3, dest); + if(n < 1000) + { + dest.push_back(n / 100 + '0'); + n = n % 100; + dest.push_back((n / 10) + '0'); + dest.push_back((n % 10) + '0'); + } + else + { + append_int(n, dest); + } } + + template inline void pad6(T n, memory_buf_t &dest) {