From 27a559c5fe72dd2ee3990af6d334695222548327 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 5042eb6b6..62b8dc8af 100644 --- a/lib/config/applyrule.cpp +++ b/lib/config/applyrule.cpp @@ -61,7 +61,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 303b259e1..72c85870b 100644 --- a/lib/config/applyrule.hpp +++ b/lib/config/applyrule.hpp @@ -28,7 +28,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 9830a1dac..7373d41b4 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 (!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) { - 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 5fbc22190..d78630338 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 (!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) { - 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 36b33cfe4..74839aeaa 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 (!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) { - 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 89de8d767..fae0c8101 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 (!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) { - DebugInfo di = rule.GetDebugInfo(); + auto& di (rule.GetDebugInfo()); std::ostringstream msgbuf; msgbuf << "Evaluating 'apply' rule (" << di << ")";