X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c2505da34e3d93fa429d9f047e56257378901ee4..4b8be43e2c03939bc780b6112d841d8b839a79bb:/src/s4u/s4u_host.cpp diff --git a/src/s4u/s4u_host.cpp b/src/s4u/s4u_host.cpp index ed367e8d8f..523aee6482 100644 --- a/src/s4u/s4u_host.cpp +++ b/src/s4u/s4u_host.cpp @@ -20,7 +20,7 @@ #include "simgrid/s4u/host.hpp" #include "simgrid/s4u/storage.hpp" -std::unordered_map host_list; // FIXME: move it to Engine +std::unordered_map host_list; // FIXME: move it to Engine int MSG_HOST_LEVEL = -1; int USER_HOST_LEVEL = -1; @@ -78,11 +78,13 @@ Host* Host::by_name(std::string name) } Host* Host::by_name_or_null(const char* name) { - try { - return host_list.at(name); - } catch (std::out_of_range& e) { + return by_name_or_null(std::string(name)); +} +Host* Host::by_name_or_null(std::string name) +{ + if (host_list.find(name) == host_list.end()) return nullptr; - } + return host_list.at(name); } Host *Host::current(){