reverted std::vector back to filename_t and used pointer to array start likewise as fmt's implementation uses

pull/2736/head
Bernd Ritter 3 years ago
parent d04a85a31e
commit 43711bc7fc

@ -18,7 +18,6 @@
#include <ctime> #include <ctime>
#include <mutex> #include <mutex>
#include <string> #include <string>
#include <vector>
namespace spdlog { namespace spdlog {
namespace sinks { namespace sinks {
@ -58,12 +57,12 @@ struct daily_filename_format_calculator
// https://github.com/fmtlib/fmt/issues/2238 // https://github.com/fmtlib/fmt/issues/2238
tm_format.push_back(' '); tm_format.push_back(' ');
const size_t MIN_SIZE = 10; const size_t MIN_SIZE = 64;
std::vector<char> buf; filename_t buf;
buf.resize(MIN_SIZE); buf.resize(MIN_SIZE);
for (;;) 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) if (count != 0)
{ {
// Remove the extra space. // Remove the extra space.
@ -73,7 +72,7 @@ struct daily_filename_format_calculator
buf.resize(buf.size() * 2); buf.resize(buf.size() * 2);
} }
return std::string(buf.cbegin(), buf.cend()); return buf;
} }
private: private:

Loading…
Cancel
Save