mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Remove unnecessary dictionary lookups in the DebugHint class
refs #12457
This commit is contained in:
parent
bb7fe3334a
commit
7fcf8ece72
@ -45,12 +45,19 @@ public:
|
|||||||
inline void AddMessage(const String& message, const DebugInfo& di)
|
inline void AddMessage(const String& message, const DebugInfo& di)
|
||||||
{
|
{
|
||||||
Array::Ptr amsg = new Array();
|
Array::Ptr amsg = new Array();
|
||||||
|
|
||||||
|
{
|
||||||
|
ObjectLock olock(amsg);
|
||||||
|
|
||||||
|
amsg->Reserve(6);
|
||||||
amsg->Add(message);
|
amsg->Add(message);
|
||||||
amsg->Add(di.Path);
|
amsg->Add(di.Path);
|
||||||
amsg->Add(di.FirstLine);
|
amsg->Add(di.FirstLine);
|
||||||
amsg->Add(di.FirstColumn);
|
amsg->Add(di.FirstColumn);
|
||||||
amsg->Add(di.LastLine);
|
amsg->Add(di.LastLine);
|
||||||
amsg->Add(di.LastColumn);
|
amsg->Add(di.LastColumn);
|
||||||
|
}
|
||||||
|
|
||||||
GetMessages()->Add(amsg);
|
GetMessages()->Add(amsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,14 +65,14 @@ public:
|
|||||||
{
|
{
|
||||||
Dictionary::Ptr children = GetChildren();
|
Dictionary::Ptr children = GetChildren();
|
||||||
|
|
||||||
Dictionary::Ptr child = children->Get(name);
|
Value vchild;
|
||||||
|
|
||||||
if (!child) {
|
if (!children->Get(name, &vchild)) {
|
||||||
child = new Dictionary();
|
vchild = new Dictionary();
|
||||||
children->Set(name, child);
|
children->Set(name, vchild);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DebugHint(child);
|
return DebugHint(vchild);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::Ptr ToDictionary(void) const
|
Dictionary::Ptr ToDictionary(void) const
|
||||||
@ -81,14 +88,14 @@ private:
|
|||||||
if (!m_Hints)
|
if (!m_Hints)
|
||||||
m_Hints = new Dictionary();
|
m_Hints = new Dictionary();
|
||||||
|
|
||||||
Array::Ptr messages = m_Hints->Get("messages");
|
Value vmessages;
|
||||||
|
|
||||||
if (!messages) {
|
if (!m_Hints->Get("messages", &vmessages)) {
|
||||||
messages = new Array();
|
vmessages = new Array();
|
||||||
m_Hints->Set("messages", messages);
|
m_Hints->Set("messages", vmessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
return messages;
|
return vmessages;
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::Ptr GetChildren(void)
|
Dictionary::Ptr GetChildren(void)
|
||||||
@ -96,14 +103,14 @@ private:
|
|||||||
if (!m_Hints)
|
if (!m_Hints)
|
||||||
m_Hints = new Dictionary();
|
m_Hints = new Dictionary();
|
||||||
|
|
||||||
Dictionary::Ptr children = m_Hints->Get("properties");
|
Value vchildren;
|
||||||
|
|
||||||
if (!children) {
|
if (!m_Hints->Get("properties", &vchildren)) {
|
||||||
children = new Dictionary;
|
vchildren = new Dictionary();
|
||||||
m_Hints->Set("properties", children);
|
m_Hints->Set("properties", vchildren);
|
||||||
}
|
}
|
||||||
|
|
||||||
return children;
|
return vchildren;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user