From ea65f206e62001a6eb2cd1cdf442a326929768db Mon Sep 17 00:00:00 2001 From: zzyyyl Date: Sun, 11 Sep 2022 00:44:44 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=9C=A8=E6=9E=90=E6=9E=84=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E9=87=8C=E8=B0=83=E7=94=A8=20std::endl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAssistant/Logger.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/MeoAssistant/Logger.hpp b/src/MeoAssistant/Logger.hpp index 3a15367a39..787125cf1a 100644 --- a/src/MeoAssistant/Logger.hpp +++ b/src/MeoAssistant/Logger.hpp @@ -63,10 +63,6 @@ namespace asst std::string_view str; }; - struct _endl - {}; - static constexpr _endl endl {}; - class LogStream { public: @@ -76,6 +72,13 @@ namespace asst { (*this << ... << std::forward(buff)); } + ~LogStream() + { + m_ofs << std::endl; +#ifdef ASST_DEBUG + std::cout << std::endl; +#endif + } template LogStream& operator<<(T&& arg) @@ -83,9 +86,6 @@ namespace asst if constexpr (std::same_as>) { m_sep = std::forward(arg); } - else if constexpr (std::same_as<_endl, std::decay_t>) { - m_ofs << std::endl; - } else { if (!m_is_first) { #ifdef ASST_DEBUG @@ -210,7 +210,7 @@ namespace asst template inline void log(level lv, Args&&... args) { - log(lv, std::forward(args)...); + ((*this << lv) << ... << std::forward(args)); } void flush()