diff options
author | Shauren <shauren.trinity@gmail.com> | 2023-07-23 00:27:26 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2023-08-15 22:03:47 +0200 |
commit | 26836f865511f0f6a48c930264537637eb313cd4 (patch) | |
tree | 6a77f352a9f1de9423e46a05721266f9b89cd504 /src/common/Utilities/StringConvert.h | |
parent | 4e6118c919bd1f3cd864526345c0b9b7abcbb2e4 (diff) |
Core/Logging: Minor compile time reducing refactor of log message formatting
(cherry picked from commit 576ca241ecaea6f357a13f022fb297976aa967ca)
Diffstat (limited to 'src/common/Utilities/StringConvert.h')
-rw-r--r-- | src/common/Utilities/StringConvert.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/common/Utilities/StringConvert.h b/src/common/Utilities/StringConvert.h index 4ec3324fb33..0d11dbb6667 100644 --- a/src/common/Utilities/StringConvert.h +++ b/src/common/Utilities/StringConvert.h @@ -76,7 +76,9 @@ namespace Trinity::Impl::StringConvertImpl static std::string ToString(T val) { - std::string buf(20,'\0'); /* 2^64 is 20 decimal characters, -(2^63) is 20 including the sign */ + using buffer_size = std::integral_constant<size_t, sizeof(T) < 8 ? 11 : 20>; + + std::string buf(buffer_size::value,'\0'); /* 2^64 is 20 decimal characters, -(2^63) is 20 including the sign */ char* const start = buf.data(); char* const end = (start + buf.length()); std::to_chars_result const res = std::to_chars(start, end, val); |