Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Quick and dirty fix to speed up get_host_by_name
authorFabien Chaix <chaix@ics.forth.gr>
Thu, 16 Jun 2022 17:14:33 +0000 (20:14 +0300)
committerFabien Chaix <chaix@ics.forth.gr>
Fri, 24 Jun 2022 15:05:20 +0000 (18:05 +0300)
src/kernel/routing/NetZoneImpl.cpp

index 17afb8b..ad56002 100644 (file)
@@ -342,15 +342,21 @@ resource::SplitDuplexLinkImpl* NetZoneImpl::get_split_duplex_link_by_name_or_nul
 
 resource::HostImpl* NetZoneImpl::get_host_by_name_or_null(const std::string& name) const
 {
+
+  auto host_it = hosts_.find(name);
+  if(host_it != hosts_.end())
+        return host_it->second;
+/*
   for (auto const& [_, host] : hosts_) {
     if (host->get_name() == name)
-      return host;
-    /* keep old behavior where host and VMs were saved together on EngineImpl::hosts_
-     * get hosts returns VMs too */
+       return host;
+    / * keep old behavior where host and VMs were saved together on EngineImpl::hosts_
+     * get hosts returns VMs too * /
     auto* vm = host->get_vm_by_name_or_null(name);
     if (vm)
       return vm;
   }
+*/
 
   for (const auto* child : children_) {
     auto* host = child->get_host_by_name_or_null(name);