Optimize Service::GetHost.

Refs #5049
This commit is contained in:
Gunnar Beutner 2013-11-10 22:04:18 +01:00
parent ca9b31d4f0
commit f7171e3e90
2 changed files with 8 additions and 5 deletions

View File

@ -72,9 +72,10 @@ void Service::OnConfigLoaded(void)
} }
} }
Host::Ptr host = GetHost(); m_Host = Host::GetByName(GetHostRaw());
if (host)
host->AddService(GetSelf()); if (m_Host)
m_Host->AddService(GetSelf());
UpdateSlaveNotifications(); UpdateSlaveNotifications();
} }
@ -95,7 +96,7 @@ Service::Ptr Service::GetByNamePair(const String& hostName, const String& servic
Host::Ptr Service::GetHost(void) const Host::Ptr Service::GetHost(void) const
{ {
return Host::GetByName(GetHostRaw()); return m_Host;
} }
bool Service::IsHostCheck(void) const bool Service::IsHostCheck(void) const
@ -227,7 +228,7 @@ std::set<Host::Ptr> Service::GetParentHosts(void) const
if (dependencies) { if (dependencies) {
ObjectLock olock(dependencies); ObjectLock olock(dependencies);
BOOST_FOREACH(const Value& dependency, dependencies) { BOOST_FOREACH(const String& dependency, dependencies) {
Host::Ptr host = Host::GetByName(dependency); Host::Ptr host = Host::GetByName(dependency);
if (!host) if (!host)

View File

@ -255,6 +255,8 @@ protected:
virtual void OnConfigLoaded(void); virtual void OnConfigLoaded(void);
private: private:
Host::Ptr m_Host;
bool m_CheckRunning; bool m_CheckRunning;
long m_SchedulingOffset; long m_SchedulingOffset;