diff options
author | gabime <gmelman1@gmail.comx> | 2022-05-08 13:01:02 +0300 |
---|---|---|
committer | gabime <gmelman1@gmail.comx> | 2022-05-08 13:01:02 +0300 |
commit | 6d587f51811e2a68680707540d7b617a62da8bc9 (patch) | |
tree | bc8d882a0bba88d9e355334f1c9589387e861593 /include/spdlog | |
parent | 9b4b37312157d30de928bea8347eb4382f89db07 (diff) |
Use fmt::detail::vformat_to(buf, ...) since it is ~20ns faster than fmt::vformat_to(std::back_inserter(buf),..)
Diffstat (limited to 'include/spdlog')
-rw-r--r-- | include/spdlog/logger.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index 05a40a52..7abfb0d8 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -364,7 +364,12 @@ protected: SPDLOG_TRY { memory_buf_t buf; +#ifdef SPDLOG_USE_STD_FORMAT fmt_lib::vformat_to(std::back_inserter(buf), fmt, fmt_lib::make_format_args(std::forward<Args>(args)...)); +#else + //seems that fmt::detail::vformat_to(buf, ...) is ~20ns faster than fmt::vformat_to(std::back_inserter(buf),..) + fmt::detail::vformat_to(buf, fmt, fmt::make_format_args(std::forward<Args>(args)...)); +#endif details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size())); log_it_(log_msg, log_enabled, traceback_enabled); @@ -386,7 +391,11 @@ protected: { // format to wmemory_buffer and convert to utf8 wmemory_buf_t wbuf; +#ifdef SPDLOG_USE_STD_FORMAT fmt_lib::vformat_to(std::back_inserter(wbuf), fmt, fmt_lib::make_format_args<fmt_lib::wformat_context>(std::forward<Args>(args)...)); +#else + fmt::detail::vformat_to(wbuf, fmt, fmt::make_format_args<fmt::wformat_context>(std::forward<Args>(args)...)); +#endif memory_buf_t buf; details::os::wstr_to_utf8buf(wstring_view_t(wbuf.data(), wbuf.size()), buf); |