From 43711bc7fc5e821ca01cfb6dbebe194a23d8d0cb Mon Sep 17 00:00:00 2001 From: Bernd Ritter Date: Thu, 18 May 2023 11:10:04 +0200 Subject: [PATCH] reverted std::vector back to filename_t and used pointer to array start likewise as fmt's implementation uses --- include/spdlog/sinks/daily_file_sink.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/spdlog/sinks/daily_file_sink.h b/include/spdlog/sinks/daily_file_sink.h index 31516ee2..9c08182e 100644 --- a/include/spdlog/sinks/daily_file_sink.h +++ b/include/spdlog/sinks/daily_file_sink.h @@ -18,7 +18,6 @@ #include #include #include -#include namespace spdlog { namespace sinks { @@ -58,12 +57,12 @@ struct daily_filename_format_calculator // https://github.com/fmtlib/fmt/issues/2238 tm_format.push_back(' '); - const size_t MIN_SIZE = 10; - std::vector buf; + const size_t MIN_SIZE = 64; + filename_t buf; buf.resize(MIN_SIZE); for (;;) { - size_t count = strftime(buf.data(), buf.size(), tm_format.c_str(), &now_tm); + size_t count = strftime(&buf[0], buf.size(), tm_format.c_str(), &now_tm); if (count != 0) { // Remove the extra space. @@ -73,7 +72,7 @@ struct daily_filename_format_calculator buf.resize(buf.size() * 2); } - return std::string(buf.cbegin(), buf.cend()); + return buf; } private: