From 98e4eb98f9fd88f206070cea9076239c2cf882d4 Mon Sep 17 00:00:00 2001 From: gabi Date: Wed, 3 Dec 2014 00:50:49 +0200 Subject: [PATCH] small optimization in default formatting (unsigned ints) --- .../spdlog/details/pattern_formatter_impl.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/include/spdlog/details/pattern_formatter_impl.h b/include/spdlog/details/pattern_formatter_impl.h index 8ee826a1..bc2cc6f0 100644 --- a/include/spdlog/details/pattern_formatter_impl.h +++ b/include/spdlog/details/pattern_formatter_impl.h @@ -345,7 +345,7 @@ class v_formatter :public flag_formatter { void format(details::log_msg& msg) override { - msg.formatted << fmt::BasicStringRef(msg.raw.data(), msg.raw.size()); + msg.formatted << fmt::StringRef(msg.raw.data(), msg.raw.size()); } }; @@ -404,16 +404,16 @@ class full_formatter :public flag_formatter msg.raw.str());*/ // Faster (albeit uglier) way to format the line (5.6 million lines/sec under 10 threads) - msg.formatted << '[' << msg.tm_time.tm_year + 1900 << '-' - << fmt::pad(msg.tm_time.tm_mon + 1, 2, '0') << '-' - << fmt::pad(msg.tm_time.tm_mday, 2, '0') << ' ' - << fmt::pad(msg.tm_time.tm_hour, 2, '0') << ':' - << fmt::pad(msg.tm_time.tm_min, 2, '0') << ':' - << fmt::pad(msg.tm_time.tm_sec, 2, '0') << '.' - << fmt::pad(static_cast(millis), 3, '0') << "] "; + msg.formatted << '[' << static_cast(msg.tm_time.tm_year + 1900) << '-' + << fmt::pad(static_cast(msg.tm_time.tm_mon + 1), 2, '0') << '-' + << fmt::pad(static_cast(msg.tm_time.tm_mday), 2, '0') << ' ' + << fmt::pad(static_cast(msg.tm_time.tm_hour), 2, '0') << ':' + << fmt::pad(static_cast(msg.tm_time.tm_min), 2, '0') << ':' + << fmt::pad(static_cast(msg.tm_time.tm_sec), 2, '0') << '.' + << fmt::pad(static_cast(millis), 3, '0') << "] "; msg.formatted << '[' << msg.logger_name << "] [" << level::to_str(msg.level) << "] "; - msg.formatted << fmt::BasicStringRef(msg.raw.data(), msg.raw.size()); + msg.formatted << fmt::StringRef(msg.raw.data(), msg.raw.size()); } };