]> granicus.if.org Git - icinga2/commitdiff
Optimize Service::GetHost.
authorGunnar Beutner <gunnar@beutner.name>
Sun, 10 Nov 2013 21:04:18 +0000 (22:04 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Sun, 10 Nov 2013 21:04:18 +0000 (22:04 +0100)
Refs #5049

lib/icinga/service.cpp
lib/icinga/service.h

index dbec5f49cf2dd746762b54043c2fd89e7aa35129..1eb4d84c1f173b1808f6102ee97a3276d2903607 100644 (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)
index 1ae8fca8a36b227d17088047c681bd38b50baf2b..c11e0ea85e7095bcae74c8885ccb487a5786ecd5 100644 (file)
@@ -255,6 +255,8 @@ protected:
        virtual void OnConfigLoaded(void);
 
 private:
+       Host::Ptr m_Host;
+
        bool m_CheckRunning;
        long m_SchedulingOffset;