ApplyRule#GetDebugInfo(): return by const ref to avoid malloc()

This commit is contained in:
Alexander A. Klimov 2022-10-28 15:33:44 +02:00
parent dd7009dc63
commit 27a559c5fe
6 changed files with 10 additions and 10 deletions

View File

@ -61,7 +61,7 @@ bool ApplyRule::GetIgnoreOnError() const
return m_IgnoreOnError; return m_IgnoreOnError;
} }
DebugInfo ApplyRule::GetDebugInfo() const const DebugInfo& ApplyRule::GetDebugInfo() const
{ {
return m_DebugInfo; return m_DebugInfo;
} }

View File

@ -28,7 +28,7 @@ public:
String GetFVVar() const; String GetFVVar() const;
Expression::Ptr GetFTerm() const; Expression::Ptr GetFTerm() const;
bool GetIgnoreOnError() const; bool GetIgnoreOnError() const;
DebugInfo GetDebugInfo() const; const DebugInfo& GetDebugInfo() const;
Dictionary::Ptr GetScope() const; Dictionary::Ptr GetScope() const;
void AddMatch(); void AddMatch();
bool HasMatches() const; bool HasMatches() const;

View File

@ -22,7 +22,7 @@ bool Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, cons
if (!rule.EvaluateFilter(frame)) if (!rule.EvaluateFilter(frame))
return false; return false;
DebugInfo di = rule.GetDebugInfo(); auto& di (rule.GetDebugInfo());
#ifdef _DEBUG #ifdef _DEBUG
Log(LogDebug, "Dependency") 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 Dependency::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule)
{ {
DebugInfo di = rule.GetDebugInfo(); auto& di (rule.GetDebugInfo());
std::ostringstream msgbuf; std::ostringstream msgbuf;
msgbuf << "Evaluating 'apply' rule (" << di << ")"; msgbuf << "Evaluating 'apply' rule (" << di << ")";

View File

@ -22,7 +22,7 @@ bool Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, co
if (!rule.EvaluateFilter(frame)) if (!rule.EvaluateFilter(frame))
return false; return false;
DebugInfo di = rule.GetDebugInfo(); auto& di (rule.GetDebugInfo());
#ifdef _DEBUG #ifdef _DEBUG
Log(LogDebug, "Notification") 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 Notification::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule)
{ {
DebugInfo di = rule.GetDebugInfo(); auto& di (rule.GetDebugInfo());
std::ostringstream msgbuf; std::ostringstream msgbuf;
msgbuf << "Evaluating 'apply' rule (" << di << ")"; msgbuf << "Evaluating 'apply' rule (" << di << ")";

View File

@ -21,7 +21,7 @@ bool ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkabl
if (!rule.EvaluateFilter(frame)) if (!rule.EvaluateFilter(frame))
return false; return false;
DebugInfo di = rule.GetDebugInfo(); auto& di (rule.GetDebugInfo());
#ifdef _DEBUG #ifdef _DEBUG
Log(LogDebug, "ScheduledDowntime") 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 ScheduledDowntime::EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule)
{ {
DebugInfo di = rule.GetDebugInfo(); auto& di (rule.GetDebugInfo());
std::ostringstream msgbuf; std::ostringstream msgbuf;
msgbuf << "Evaluating 'apply' rule (" << di << ")"; msgbuf << "Evaluating 'apply' rule (" << di << ")";

View File

@ -21,7 +21,7 @@ bool Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& nam
if (!rule.EvaluateFilter(frame)) if (!rule.EvaluateFilter(frame))
return false; return false;
DebugInfo di = rule.GetDebugInfo(); auto& di (rule.GetDebugInfo());
#ifdef _DEBUG #ifdef _DEBUG
Log(LogDebug, "Service") 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 Service::EvaluateApplyRule(const Host::Ptr& host, const ApplyRule& rule)
{ {
DebugInfo di = rule.GetDebugInfo(); auto& di (rule.GetDebugInfo());
std::ostringstream msgbuf; std::ostringstream msgbuf;
msgbuf << "Evaluating 'apply' rule (" << di << ")"; msgbuf << "Evaluating 'apply' rule (" << di << ")";