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

View File

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