From f7171e3e90243dbdd4c2ede90e82151543d94c35 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 10 Nov 2013 22:04:18 +0100 Subject: [PATCH] Optimize Service::GetHost. Refs #5049 --- lib/icinga/service.cpp | 11 ++++++----- lib/icinga/service.h | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/icinga/service.cpp b/lib/icinga/service.cpp index dbec5f49c..1eb4d84c1 100644 --- a/lib/icinga/service.cpp +++ b/lib/icinga/service.cpp @@ -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 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) diff --git a/lib/icinga/service.h b/lib/icinga/service.h index 1ae8fca8a..c11e0ea85 100644 --- a/lib/icinga/service.h +++ b/lib/icinga/service.h @@ -255,6 +255,8 @@ protected: virtual void OnConfigLoaded(void); private: + Host::Ptr m_Host; + bool m_CheckRunning; long m_SchedulingOffset; -- 2.40.0