From f3676d7f18928605d9e43ca1dd78de0cca71b07c Mon Sep 17 00:00:00 2001 From: brain5lug Date: Sun, 7 Mar 2021 23:55:55 +0300 Subject: [PATCH] logging opimization --- libi2pd/Log.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libi2pd/Log.h b/libi2pd/Log.h index 972a00e1..08c401a9 100644 --- a/libi2pd/Log.h +++ b/libi2pd/Log.h @@ -148,7 +148,7 @@ namespace log { LogLevel level; /**< message level */ std::thread::id tid; /**< id of thread that generated message */ - LogMsg (LogLevel lvl, std::time_t ts, const std::string & txt): timestamp(ts), text(txt), level(lvl) {}; + LogMsg (LogLevel lvl, std::time_t ts, std::string&& txt): timestamp(ts), text(std::move(txt)), level(lvl) {} }; Log & Logger(); @@ -189,7 +189,7 @@ void LogPrint (LogLevel level, TArgs&&... args) noexcept return; // fold message to single string - std::stringstream ss(""); + std::stringstream ss; #if (__cplusplus >= 201703L) // C++ 17 or higher (LogPrint (ss, std::forward(args)), ...); @@ -197,7 +197,7 @@ void LogPrint (LogLevel level, TArgs&&... args) noexcept LogPrint (ss, std::forward(args)...); #endif - auto msg = std::make_shared(level, std::time(nullptr), ss.str()); + auto msg = std::make_shared(level, std::time(nullptr), std::move(ss).str()); msg->tid = std::this_thread::get_id(); log.Append(msg); }