From 39fde514745ddfef536ae4080cccd50bb3107f94 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 28 Oct 2022 15:33:44 +0200 Subject: [PATCH] ApplyRule#GetDebugInfo(): return by const ref to avoid malloc() --- lib/config/applyrule.cpp | 2 +- lib/config/applyrule.hpp | 2 +- lib/icinga/dependency-apply.cpp | 4 ++-- lib/icinga/notification-apply.cpp | 4 ++-- lib/icinga/scheduleddowntime-apply.cpp | 4 ++-- lib/icinga/service-apply.cpp | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/config/applyrule.cpp b/lib/config/applyrule.cpp index 5cfbf9e35..308321e60 100644 --- a/lib/config/applyrule.cpp +++ b/lib/config/applyrule.cpp @@ -57,7 +57,7 @@ bool ApplyRule::GetIgnoreOnError() const return m_IgnoreOnError; } -DebugInfo ApplyRule::GetDebugInfo() const +const DebugInfo& ApplyRule::GetDebugInfo() const { return m_DebugInfo; } diff --git a/lib/config/applyrule.hpp b/lib/config/applyrule.hpp index 6b6fca8f8..cbc79e34f 100644 --- a/lib/config/applyrule.hpp +++ b/lib/config/applyrule.hpp @@ -59,7 +59,7 @@ public: String GetFVVar() const; Expression::Ptr GetFTerm() const; bool GetIgnoreOnError() const; - DebugInfo GetDebugInfo() const; + const DebugInfo& GetDebugInfo() const; Dictionary::Ptr GetScope() const; void AddMatch(); bool HasMatches() const; diff --git a/lib/icinga/dependency-apply.cpp b/lib/icinga/dependency-apply.cpp index 7e39c0ccc..6b063f1a9 100644 --- a/lib/icinga/dependency-apply.cpp +++ b/lib/icinga/dependency-apply.cpp @@ -22,7 +22,7 @@ bool Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, cons if (!skipFilter && !rule.EvaluateFilter(frame)) return false; - DebugInfo di = rule.GetDebugInfo(); + auto& di (rule.GetDebugInfo()); #ifdef _DEBUG Log(LogDebug, "Dependency") @@ -64,7 +64,7 @@ bool Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, cons bool Dependency::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule, bool skipFilter) { - DebugInfo di = rule.GetDebugInfo(); + auto& di (rule.GetDebugInfo()); std::ostringstream msgbuf; msgbuf << "Evaluating 'apply' rule (" << di << ")"; diff --git a/lib/icinga/notification-apply.cpp b/lib/icinga/notification-apply.cpp index de986a2cd..54e162dc4 100644 --- a/lib/icinga/notification-apply.cpp +++ b/lib/icinga/notification-apply.cpp @@ -22,7 +22,7 @@ bool Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, co if (!skipFilter && !rule.EvaluateFilter(frame)) return false; - DebugInfo di = rule.GetDebugInfo(); + auto& di (rule.GetDebugInfo()); #ifdef _DEBUG Log(LogDebug, "Notification") @@ -63,7 +63,7 @@ bool Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, co bool Notification::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule, bool skipFilter) { - DebugInfo di = rule.GetDebugInfo(); + auto& di (rule.GetDebugInfo()); std::ostringstream msgbuf; msgbuf << "Evaluating 'apply' rule (" << di << ")"; diff --git a/lib/icinga/scheduleddowntime-apply.cpp b/lib/icinga/scheduleddowntime-apply.cpp index be1b25cba..4a3256988 100644 --- a/lib/icinga/scheduleddowntime-apply.cpp +++ b/lib/icinga/scheduleddowntime-apply.cpp @@ -21,7 +21,7 @@ bool ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkabl if (!skipFilter && !rule.EvaluateFilter(frame)) return false; - DebugInfo di = rule.GetDebugInfo(); + auto& di (rule.GetDebugInfo()); #ifdef _DEBUG Log(LogDebug, "ScheduledDowntime") @@ -62,7 +62,7 @@ bool ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkabl bool ScheduledDowntime::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule, bool skipFilter) { - DebugInfo di = rule.GetDebugInfo(); + auto& di (rule.GetDebugInfo()); std::ostringstream msgbuf; msgbuf << "Evaluating 'apply' rule (" << di << ")"; diff --git a/lib/icinga/service-apply.cpp b/lib/icinga/service-apply.cpp index 648d6d04f..06d88f1d3 100644 --- a/lib/icinga/service-apply.cpp +++ b/lib/icinga/service-apply.cpp @@ -21,7 +21,7 @@ bool Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& nam if (!skipFilter && !rule.EvaluateFilter(frame)) return false; - DebugInfo di = rule.GetDebugInfo(); + auto& di (rule.GetDebugInfo()); #ifdef _DEBUG Log(LogDebug, "Service") @@ -57,7 +57,7 @@ bool Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& nam bool Service::EvaluateApplyRule(const Host::Ptr& host, const ApplyRule& rule, bool skipFilter) { - DebugInfo di = rule.GetDebugInfo(); + auto& di (rule.GetDebugInfo()); std::ostringstream msgbuf; msgbuf << "Evaluating 'apply' rule (" << di << ")";