Optimize fmt_helper::pad3()

This commit is contained in:
gabime 2020-04-11 19:50:19 +03:00
parent 0a14e491ab
commit 76389e057f

View File

@ -73,9 +73,21 @@ inline void pad_uint(T n, unsigned int width, memory_buf_t &dest)
template<typename T> template<typename T>
inline void pad3(T n, memory_buf_t &dest) 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<typename T> template<typename T>
inline void pad6(T n, memory_buf_t &dest) inline void pad6(T n, memory_buf_t &dest)
{ {