From: Fabien Chaix Date: Thu, 16 Jun 2022 17:14:33 +0000 (+0300) Subject: Quick and dirty fix to speed up get_host_by_name X-Git-Tag: v3.32~175^2~2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0405eed965d6590a9691519a2078e43463b13148 Quick and dirty fix to speed up get_host_by_name --- diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 17afb8b3c0..ad56002aec 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -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);