From 8fbfd0f7fab0bf2a7b1e2d7bb6b27d24032b18ae Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 13 Aug 2018 21:44:53 -0400 Subject: [PATCH] logging/backend: Use const reference to refer to log filter The filter is returned via const reference, so this was making a pointless copy of the entire filter every time a message was being pushed into the logger instance. --- src/common/logging/backend.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 05ea990f15..6d9989e146 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -280,13 +280,14 @@ Backend* GetBackend(std::string_view backend_name) { void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename, unsigned int line_num, const char* function, const char* format, const fmt::format_args& args) { - auto filter = Impl::Instance().GetGlobalFilter(); + auto& instance = Impl::Instance(); + const auto& filter = instance.GetGlobalFilter(); if (!filter.CheckMessage(log_class, log_level)) return; Entry entry = CreateEntry(log_class, log_level, filename, line_num, function, fmt::vformat(format, args)); - Impl::Instance().PushEntry(std::move(entry)); + instance.PushEntry(std::move(entry)); } } // namespace Log