Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Avoid costly exceptions when looking into a map.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 2 Aug 2017 13:49:50 +0000 (15:49 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 2 Aug 2017 13:54:29 +0000 (15:54 +0200)
19 files changed:
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/VivaldiZone.cpp
src/s4u/s4u_engine.cpp
src/s4u/s4u_host.cpp
src/simdag/sd_daxloader.cpp
src/simdag/sd_dotloader.cpp
src/simix/ActorImpl.cpp
src/smpi/include/smpi_keyvals.hpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_f2c.cpp
src/smpi/mpi/smpi_group.cpp
src/smpi/mpi/smpi_info.cpp
src/surf/FileImpl.cpp
src/surf/PropertyHolder.cpp
src/surf/network_ib.cpp
src/surf/network_interface.cpp
src/surf/sg_platf.cpp
src/xbt/config.cpp
src/xbt/xbt_replay.cpp

index 5f846b1..b26cf09 100644 (file)
@@ -260,20 +260,18 @@ bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst,
     for (int i = 0; i < max; i++) {
       if (i <= max_index_src && max <= max_index_dst) {
         key = {path_src.at(i)->netpoint_, path_dst.at(max)->netpoint_};
     for (int i = 0; i < max; i++) {
       if (i <= max_index_src && max <= max_index_dst) {
         key = {path_src.at(i)->netpoint_, path_dst.at(max)->netpoint_};
-        try {
-          bypassedRoute = bypassRoutes_.at(key);
+        auto bpr = bypassRoutes_.find(key);
+        if (bpr != bypassRoutes_.end()) {
+          bypassedRoute = bpr->second;
           break;
           break;
-        } catch (std::out_of_range& unfound) {
-          // Do nothing
         }
       }
       if (max <= max_index_src && i <= max_index_dst) {
         key = {path_src.at(max)->netpoint_, path_dst.at(i)->netpoint_};
         }
       }
       if (max <= max_index_src && i <= max_index_dst) {
         key = {path_src.at(max)->netpoint_, path_dst.at(i)->netpoint_};
-        try {
-          bypassedRoute = bypassRoutes_.at(key);
+        auto bpr = bypassRoutes_.find(key);
+        if (bpr != bypassRoutes_.end()) {
+          bypassedRoute = bpr->second;
           break;
           break;
-        } catch (std::out_of_range& unfound) {
-          // Do nothing
         }
       }
     }
         }
       }
     }
@@ -283,11 +281,10 @@ bool NetZoneImpl::getBypassRoute(routing::NetPoint* src, routing::NetPoint* dst,
 
     if (max <= max_index_src && max <= max_index_dst) {
       key = {path_src.at(max)->netpoint_, path_dst.at(max)->netpoint_};
 
     if (max <= max_index_src && max <= max_index_dst) {
       key = {path_src.at(max)->netpoint_, path_dst.at(max)->netpoint_};
-      try {
-        bypassedRoute = bypassRoutes_.at(key);
+      auto bpr = bypassRoutes_.find(key);
+      if (bpr != bypassRoutes_.end()) {
+        bypassedRoute = bpr->second;
         break;
         break;
-      } catch (std::out_of_range& unfound) {
-        // Do nothing
       }
     }
   }
       }
     }
   }
index 8ebb7fa..80c785f 100644 (file)
@@ -86,25 +86,27 @@ void VivaldiZone::getLocalRoute(NetPoint* src, NetPoint* dst, sg_platf_route_cba
   }
 
   /* Retrieve the private links */
   }
 
   /* Retrieve the private links */
-  try {
-    std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(src->id());
+  auto src_link = privateLinks_.find(src->id());
+  if (src_link != privateLinks_.end()) {
+    std::pair<surf::LinkImpl*, surf::LinkImpl*> info = src_link->second;
     if (info.first) {
       route->link_list->push_back(info.first);
       if (lat)
         *lat += info.first->latency();
     }
     if (info.first) {
       route->link_list->push_back(info.first);
       if (lat)
         *lat += info.first->latency();
     }
-  } catch (std::out_of_range& unfound) {
+  } else {
     XBT_DEBUG("Source of private link (%u) doesn't exist", src->id());
   }
 
     XBT_DEBUG("Source of private link (%u) doesn't exist", src->id());
   }
 
-  try {
-    std::pair<surf::LinkImpl*, surf::LinkImpl*> info = privateLinks_.at(dst->id());
+  auto dst_link = privateLinks_.find(dst->id());
+  if (dst_link != privateLinks_.end()) {
+    std::pair<surf::LinkImpl*, surf::LinkImpl*> info = dst_link->second;
     if (info.second) {
       route->link_list->push_back(info.second);
       if (lat)
         *lat += info.second->latency();
     }
     if (info.second) {
       route->link_list->push_back(info.second);
       if (lat)
         *lat += info.second->latency();
     }
-  } catch (std::out_of_range& unfound) {
+  } else {
     XBT_DEBUG("Destination of private link (%u) doesn't exist", dst->id());
   }
 
     XBT_DEBUG("Destination of private link (%u) doesn't exist", dst->id());
   }
 
index e061713..4c13de0 100644 (file)
@@ -128,11 +128,8 @@ NetZone* Engine::getNetzoneByNameOrNull(const char* name)
 /** @brief Retrieve the netpoint of the given name (or nullptr if not found) */
 simgrid::kernel::routing::NetPoint* Engine::getNetpointByNameOrNull(const char* name)
 {
 /** @brief Retrieve the netpoint of the given name (or nullptr if not found) */
 simgrid::kernel::routing::NetPoint* Engine::getNetpointByNameOrNull(const char* name)
 {
-  try {
-    return pimpl->netpoints_.at(name);
-  } catch (std::out_of_range& unfound) {
-    return nullptr;
-  }
+  auto netp = pimpl->netpoints_.find(name);
+  return netp == pimpl->netpoints_.end() ? nullptr : netp->second;
 }
 /** @brief Fill the provided vector with all existing netpoints */
 void Engine::getNetpointList(std::vector<simgrid::kernel::routing::NetPoint*>* list)
 }
 /** @brief Fill the provided vector with all existing netpoints */
 void Engine::getNetpointList(std::vector<simgrid::kernel::routing::NetPoint*>* list)
index cd08364..5439ce8 100644 (file)
@@ -87,11 +87,8 @@ Host* Host::by_name_or_null(const char* name)
 }
 Host* Host::by_name_or_null(std::string name)
 {
 }
 Host* Host::by_name_or_null(std::string name)
 {
-  try {
-    return host_list.at(name);
-  } catch (std::out_of_range& unfound) {
-    return nullptr;
-  }
+  auto host = host_list.find(name);
+  return host == host_list.end() ? nullptr : host->second;
 }
 
 Host *Host::current(){
 }
 
 Host *Host::current(){
index 843e43e..f18920c 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2016. The SimGrid Team.
+/* Copyright (c) 2009-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -318,9 +318,10 @@ void STag_dax__uses()
 static SD_task_t current_child;
 void STag_dax__child()
 {
 static SD_task_t current_child;
 void STag_dax__child()
 {
-  try {
-    current_child = jobs.at(A_dax__child_ref);
-  } catch (std::out_of_range& unfound) {
+  auto job = jobs.find(A_dax__child_ref);
+  if (job != jobs.end()) {
+    current_child = job->second;
+  } else {
     throw std::out_of_range(std::string("Parse error on line ") + std::to_string(dax_lineno) +
                             ": Asked to add dependencies to the non-existent " + A_dax__child_ref + "task");
   }
     throw std::out_of_range(std::string("Parse error on line ") + std::to_string(dax_lineno) +
                             ": Asked to add dependencies to the non-existent " + A_dax__child_ref + "task");
   }
@@ -333,11 +334,12 @@ void ETag_dax__child()
 
 void STag_dax__parent()
 {
 
 void STag_dax__parent()
 {
-  try {
-    SD_task_t parent = jobs.at(A_dax__parent_ref);
+  auto job = jobs.find(A_dax__parent_ref);
+  if (job != jobs.end()) {
+    SD_task_t parent = job->second;
     SD_task_dependency_add(nullptr, nullptr, parent, current_child);
     XBT_DEBUG("Control-flow dependency from %s to %s", current_child->name, parent->name);
     SD_task_dependency_add(nullptr, nullptr, parent, current_child);
     XBT_DEBUG("Control-flow dependency from %s to %s", current_child->name, parent->name);
-  } catch (std::out_of_range& unfound) {
+  } else {
     throw std::out_of_range(std::string("Parse error on line ") + std::to_string(dax_lineno) +
                             ": Asked to add a dependency from " + current_child->name + " to " + A_dax__parent_ref +
                             ", but " + A_dax__parent_ref + " does not exist");
     throw std::out_of_range(std::string("Parse error on line ") + std::to_string(dax_lineno) +
                             ": Asked to add a dependency from " + current_child->name + " to " + A_dax__parent_ref +
                             ", but " + A_dax__parent_ref + " does not exist");
index b200887..0960689 100644 (file)
@@ -103,9 +103,10 @@ xbt_dynar_t SD_dotload_generic(const char* filename, bool sequential, bool sched
         if ((performer != -1 && order != -1) && performer < static_cast<int>(sg_host_count())) {
           /* required parameters are given and less performers than hosts are required */
           XBT_DEBUG ("Task '%s' is scheduled on workstation '%d' in position '%d'", task->name, performer, order);
         if ((performer != -1 && order != -1) && performer < static_cast<int>(sg_host_count())) {
           /* required parameters are given and less performers than hosts are required */
           XBT_DEBUG ("Task '%s' is scheduled on workstation '%d' in position '%d'", task->name, performer, order);
-          try {
-            computer = computers.at(char_performer);
-          } catch (std::out_of_range& unfound) {
+          auto comp = computers.find(char_performer);
+          if (comp != computers.end()) {
+            computer = comp->second;
+          } else {
             computer = new std::vector<SD_task_t>;
             computers.insert({char_performer, computer});
           }
             computer = new std::vector<SD_task_t>;
             computers.insert({char_performer, computer});
           }
index 6bd02ca..bd2ab82 100644 (file)
@@ -829,11 +829,8 @@ xbt_dynar_t SIMIX_process_get_runnable()
 /** @brief Returns the process from PID. */
 smx_actor_t SIMIX_process_from_PID(aid_t PID)
 {
 /** @brief Returns the process from PID. */
 smx_actor_t SIMIX_process_from_PID(aid_t PID)
 {
-  try {
-    return simix_global->process_list.at(PID);
-  } catch (std::out_of_range& unfound) {
-    return nullptr;
-  }
+  auto process = simix_global->process_list.find(PID);
+  return process == simix_global->process_list.end() ? nullptr : process->second;
 }
 
 /** @brief returns a dynar containing all currently existing processes */
 }
 
 /** @brief returns a dynar containing all currently existing processes */
index bc3e2af..986540f 100644 (file)
@@ -109,11 +109,12 @@ template <typename T> int Keyval::attr_get(int keyval, void* attr_value, int* fl
     *flag=0;
     return MPI_SUCCESS;
   }
     *flag=0;
     return MPI_SUCCESS;
   }
-  try {
-    *static_cast<void**>(attr_value) = attributes()->at(keyval);
+  const auto& attribs = attributes();
+  auto attr           = attribs->find(keyval);
+  if (attr != attribs->end()) {
+    *static_cast<void**>(attr_value) = attr->second;
     *flag=1;
     *flag=1;
-  }
-  catch (const std::out_of_range& oor) {
+  } else {
     *flag=0;
   }
   return MPI_SUCCESS;
     *flag=0;
   }
   return MPI_SUCCESS;
@@ -140,12 +141,13 @@ template <typename T> void Keyval::cleanup_attr(){
   if (not attributes()->empty()) {
     int flag=0;
     for(auto it : attributes_){
   if (not attributes()->empty()) {
     int flag=0;
     for(auto it : attributes_){
-      try{
-        smpi_key_elem elem = T::keyvals_.at(it.first);
+      auto elm = T::keyvals_.find(it.first);
+      if (elm != T::keyvals_.end()) {
+        smpi_key_elem elem = elm->second;
         if(elem != nullptr){
           call_deleter<T>((T*)this, elem, it.first,it.second,&flag);
         }
         if(elem != nullptr){
           call_deleter<T>((T*)this, elem, it.first,it.second,&flag);
         }
-      }catch(const std::out_of_range& oor) {
+      } else {
         //already deleted, not a problem;
         flag=0;
       }
         //already deleted, not a problem;
         flag=0;
       }
index 23a4bd6..051be8c 100644 (file)
@@ -452,11 +452,9 @@ MPI_Comm Comm::f2c(int id) {
     return MPI_COMM_WORLD;
   } else if(F2C::f2c_lookup() != nullptr && id >= 0) {
     char key[KEY_SIZE];
     return MPI_COMM_WORLD;
   } else if(F2C::f2c_lookup() != nullptr && id >= 0) {
     char key[KEY_SIZE];
-    try {
-      return static_cast<MPI_Comm>(F2C::f2c_lookup()->at(get_key_id(key, id)));
-    } catch (std::out_of_range& unfound) {
-      return MPI_COMM_NULL;
-    }
+    const auto& lookup = F2C::f2c_lookup();
+    auto comm          = lookup->find(get_key_id(key, id));
+    return comm == lookup->end() ? MPI_COMM_NULL : static_cast<MPI_Comm>(comm->second);
   } else {
     return MPI_COMM_NULL;
   }
   } else {
     return MPI_COMM_NULL;
   }
index ffd795f..532f3e4 100644 (file)
@@ -90,11 +90,8 @@ F2C* F2C::f2c(int id)
 
   if(id >= 0){
     char key[KEY_SIZE];
 
   if(id >= 0){
     char key[KEY_SIZE];
-    try {
-      return f2c_lookup_->at(get_key(key, id));
-    } catch (std::out_of_range& unfound) {
-      return nullptr;
-    }
+    auto comm = f2c_lookup_->find(get_key(key, id));
+    return comm == f2c_lookup_->end() ? nullptr : comm->second;
   }else
     return nullptr;
 }
   }else
     return nullptr;
 }
index 8cc21c3..2320768 100644 (file)
@@ -73,11 +73,8 @@ int Group::rank(int index)
 {
   if (this == MPI_GROUP_EMPTY)
     return MPI_UNDEFINED;
 {
   if (this == MPI_GROUP_EMPTY)
     return MPI_UNDEFINED;
-  try {
-    return index_to_rank_map_.at(index);
-  } catch (std::out_of_range& unfound) {
-    return MPI_UNDEFINED;
-  }
+  auto rank = index_to_rank_map_.find(index);
+  return rank == index_to_rank_map_.end() ? MPI_UNDEFINED : rank->second;
 }
 
 void Group::ref()
 }
 
 void Group::ref()
index ff3c853..3698e30 100644 (file)
@@ -32,15 +32,16 @@ void Info::set(char *key, char *value){
 
 int Info::get(char *key, int valuelen, char *value, int *flag){
   *flag=false;
 
 int Info::get(char *key, int valuelen, char *value, int *flag){
   *flag=false;
-  try {
-    std::string tmpvalue = map_.at(key);
+  auto val = map_.find(key);
+  if (val != map_.end()) {
+    std::string tmpvalue = val->second;
 
     memset(value, 0, valuelen);
     memcpy(value, tmpvalue.c_str(),
            (tmpvalue.length() + 1 < static_cast<size_t>(valuelen)) ? tmpvalue.length() + 1 : valuelen);
     *flag=true;
     return MPI_SUCCESS;
 
     memset(value, 0, valuelen);
     memcpy(value, tmpvalue.c_str(),
            (tmpvalue.length() + 1 < static_cast<size_t>(valuelen)) ? tmpvalue.length() + 1 : valuelen);
     *flag=true;
     return MPI_SUCCESS;
-  } catch (std::out_of_range& unfound) {
+  } else {
     return MPI_ERR_INFO_KEY;
   }
 }
     return MPI_ERR_INFO_KEY;
   }
 }
@@ -71,11 +72,12 @@ int Info::get_nthkey(int n, char *key){
 
 int Info::get_valuelen(char *key, int *valuelen, int *flag){
   *flag=false;
 
 int Info::get_valuelen(char *key, int *valuelen, int *flag){
   *flag=false;
-  try {
-    *valuelen = map_.at(key).length();
+  auto val = map_.find(key);
+  if (val != map_.end()) {
+    *valuelen = val->second.length();
     *flag=true;
     return MPI_SUCCESS;
     *flag=true;
     return MPI_SUCCESS;
-  } catch (std::out_of_range& unfound) {
+  } else {
     return MPI_ERR_INFO_KEY;
   }
 }
     return MPI_ERR_INFO_KEY;
   }
 }
index e454c3a..fbb70a7 100644 (file)
@@ -17,9 +17,10 @@ FileImpl::FileImpl(sg_storage_t st, std::string path, std::string mount) : path_
   location_ = st->getImpl();
   std::map<std::string, sg_size_t>* content = location_->getContent();
   // if file does not exist create an empty file
   location_ = st->getImpl();
   std::map<std::string, sg_size_t>* content = location_->getContent();
   // if file does not exist create an empty file
-  try {
-    size_ = content->at(path);
-  } catch (std::out_of_range& unfound) {
+  auto sz = content->find(path);
+  if (sz != content->end()) {
+    size_ = sz->second;
+  } else {
     size_ = 0;
     content->insert({path, size_});
     XBT_DEBUG("File '%s' was not found, file created.", path.c_str());
     size_ = 0;
     content->insert({path, size_});
     XBT_DEBUG("File '%s' was not found, file created.", path.c_str());
@@ -96,13 +97,14 @@ void FileImpl::move(const char* fullpath)
   /* Check if the new full path is on the same mount point */
   if (not strncmp(mount_point_.c_str(), fullpath, mount_point_.size())) {
     std::map<std::string, sg_size_t>* content = location_->getContent();
   /* Check if the new full path is on the same mount point */
   if (not strncmp(mount_point_.c_str(), fullpath, mount_point_.size())) {
     std::map<std::string, sg_size_t>* content = location_->getContent();
-    try { // src file exists
-      sg_size_t new_size = content->at(path_);
+    auto sz = content->find(path_);
+    if (sz != content->end()) { // src file exists
+      sg_size_t new_size = sz->second;
       content->erase(path_);
       std::string path = std::string(fullpath).substr(mount_point_.size(), strlen(fullpath));
       content->insert({path.c_str(), new_size});
       XBT_DEBUG("Move file from %s to %s, size '%llu'", path_.c_str(), fullpath, new_size);
       content->erase(path_);
       std::string path = std::string(fullpath).substr(mount_point_.size(), strlen(fullpath));
       content->insert({path.c_str(), new_size});
       XBT_DEBUG("Move file from %s to %s, size '%llu'", path_.c_str(), fullpath, new_size);
-    } catch (std::out_of_range& unfound) {
+    } else {
       XBT_WARN("File %s doesn't exist", path_.c_str());
     }
   } else {
       XBT_WARN("File %s doesn't exist", path_.c_str());
     }
   } else {
index a6696ae..e7657a2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015. The SimGrid Team. All rights reserved.               */
+/* Copyright (c) 2015-2017. The SimGrid Team. All rights reserved.               */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -16,11 +16,8 @@ PropertyHolder::~PropertyHolder() {
 const char *PropertyHolder::getProperty(const char*key) {
   if (properties_ == nullptr)
     return nullptr;
 const char *PropertyHolder::getProperty(const char*key) {
   if (properties_ == nullptr)
     return nullptr;
-  try {
-    return properties_->at(key).c_str();
-  } catch (std::out_of_range& unfound) {
-    return nullptr;
-  }
+  auto prop = properties_->find(key);
+  return prop == properties_->end() ? nullptr : prop->second.c_str();
 }
 
 /** @brief Change the value of a given key in the property set */
 }
 
 /** @brief Change the value of a given key in the property set */
index 6018e1d..3293c9d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2015. The SimGrid Team.
+/* Copyright (c) 2014-2017. The SimGrid Team.
 *All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
 *All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -52,15 +52,17 @@ static void IB_action_init_callback(simgrid::surf::NetworkAction* action, simgri
   simgrid::surf::IBNode* act_src;
   simgrid::surf::IBNode* act_dst;
 
   simgrid::surf::IBNode* act_src;
   simgrid::surf::IBNode* act_dst;
 
-  try {
-    act_src = ibModel->active_nodes.at(src->getName());
-  } catch (std::out_of_range& unfound) {
+  auto asrc = ibModel->active_nodes.find(src->getName());
+  if (asrc != ibModel->active_nodes.end()) {
+    act_src = asrc->second;
+  } else {
     throw std::out_of_range(std::string("Could not find '") + src->getCname() + "' active comms !");
   }
 
     throw std::out_of_range(std::string("Could not find '") + src->getCname() + "' active comms !");
   }
 
-  try {
-    act_dst = ibModel->active_nodes.at(dst->getName());
-  } catch (std::out_of_range& unfound) {
+  auto adst = ibModel->active_nodes.find(dst->getName());
+  if (adst != ibModel->active_nodes.end()) {
+    act_dst = adst->second;
+  } else {
     throw std::out_of_range(std::string("Could not find '") + dst->getCname() + "' active comms !");
   }
 
     throw std::out_of_range(std::string("Could not find '") + dst->getCname() + "' active comms !");
   }
 
index fdb99fc..2944bc3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2015. The SimGrid Team.
+/* Copyright (c) 2013-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -22,11 +22,8 @@ namespace simgrid {
 
   LinkImpl* LinkImpl::byName(const char* name)
   {
 
   LinkImpl* LinkImpl::byName(const char* name)
   {
-    try {
-      return links->at(name);
-    } catch (std::out_of_range& unfound) {
-      return nullptr;
-    }
+    auto link = links->find(name);
+    return link == links->end() ? nullptr : link->second;
   }
   /** @brief Returns the amount of links in the platform */
   int LinkImpl::linksCount()
   }
   /** @brief Returns the amount of links in the platform */
   int LinkImpl::linksCount()
index d0ef69e..6813d36 100644 (file)
@@ -354,9 +354,10 @@ void sg_platf_new_storage(StorageCreationArgs* storage)
              "Refusing to add a second storage named \"%s\"", storage->id.c_str());
 
   simgrid::surf::StorageType* stype;
              "Refusing to add a second storage named \"%s\"", storage->id.c_str());
 
   simgrid::surf::StorageType* stype;
-  try {
-    stype = storage_types.at(storage->type_id);
-  } catch (std::out_of_range& unfound) {
+  auto st = storage_types.find(storage->type_id);
+  if (st != storage_types.end()) {
+    stype = st->second;
+  } else {
     xbt_die("No storage type '%s'", storage->type_id.c_str());
   }
 
     xbt_die("No storage type '%s'", storage->type_id.c_str());
   }
 
index f451949..2b1788b 100644 (file)
@@ -305,15 +305,17 @@ Config::~Config()
 
 inline ConfigurationElement* Config::getDictElement(const char* name)
 {
 
 inline ConfigurationElement* Config::getDictElement(const char* name)
 {
-  try {
-    return options.at(name);
-  } catch (std::out_of_range& unfound) {
-    try {
-      ConfigurationElement* res = aliases.at(name);
+  auto opt = options.find(name);
+  if (opt != options.end()) {
+    return opt->second;
+  } else {
+    auto als = aliases.find(name);
+    if (als != aliases.end()) {
+      ConfigurationElement* res = als->second;
       if (warn_for_aliases)
         XBT_INFO("Option %s has been renamed to %s. Consider switching.", name, res->getKey().c_str());
       return res;
       if (warn_for_aliases)
         XBT_INFO("Option %s has been renamed to %s. Consider switching.", name, res->getKey().c_str());
       return res;
-    } catch (std::out_of_range& missing_key) {
+    } else {
       throw simgrid::config::missing_key_error(std::string("Bad config key: ") + name);
     }
   }
       throw simgrid::config::missing_key_error(std::string("Bad config key: ") + name);
     }
   }
index 9571091..7a35e2f 100644 (file)
@@ -78,9 +78,10 @@ static ReplayAction* get_action(char* name)
       } else {
         // Else, I have to store it for the relevant colleague
         std::queue<ReplayAction*>* otherqueue = nullptr;
       } else {
         // Else, I have to store it for the relevant colleague
         std::queue<ReplayAction*>* otherqueue = nullptr;
-        try {
-          otherqueue = action_queues.at(evtname);
-        } catch (std::out_of_range& unfound) { // Damn. Create the queue of that guy
+        auto act                              = action_queues.find(evtname);
+        if (act != action_queues.end()) {
+          otherqueue = act->second;
+        } else { // Damn. Create the queue of that guy
           otherqueue = new std::queue<ReplayAction*>();
           action_queues.insert({evtname, otherqueue});
         }
           otherqueue = new std::queue<ReplayAction*>();
           action_queues.insert({evtname, otherqueue});
         }