Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Factorize code.
[simgrid.git] / src / instr / instr_paje_containers.cpp
index 76b9852..7541e6b 100644 (file)
@@ -71,7 +71,7 @@ simgrid::instr::Container::Container(const char* name, simgrid::instr::e_contain
     char as_typename[INSTR_DEFAULT_STR_SIZE];
     snprintf(as_typename, INSTR_DEFAULT_STR_SIZE, "L%d", this->level_);
     if (this->father_) {
-      this->type_ = simgrid::instr::Type::getOrNull(as_typename, this->father_->type_);
+      this->type_ = this->father_->type_->getChildOrNull(as_typename);
       if (this->type_ == nullptr) {
         this->type_ = simgrid::instr::Type::containerNew(as_typename, this->father_->type_);
       }
@@ -107,7 +107,7 @@ simgrid::instr::Container::Container(const char* name, simgrid::instr::e_contain
         THROWF (tracing_error, 0, "new container kind is unknown.");
         break;
     }
-    simgrid::instr::Type* type = simgrid::instr::Type::getOrNull(typeNameBuff, this->father_->type_);
+    simgrid::instr::Type* type = this->father_->type_->getChildOrNull(typeNameBuff);
     if (type == nullptr){
       this->type_ = simgrid::instr::Type::containerNew(typeNameBuff, this->father_->type_);
     }else{
@@ -121,11 +121,10 @@ simgrid::instr::Container::Container(const char* name, simgrid::instr::e_contain
   }
 
   //register all kinds by name
-  if (allContainers.find(this->name_) != allContainers.end()) {
+  if (not allContainers.emplace(this->name_, this).second) {
     THROWF(tracing_error, 1, "container %s already present in allContainers data structure", this->name_);
   }
 
-  allContainers.emplace(this->name_, this);
   XBT_DEBUG("Add container name '%s'", this->name_);
 
   //register NODE types for triva configuration
@@ -170,9 +169,8 @@ simgrid::instr::Container* PJ_container_get(const char* name)
 
 simgrid::instr::Container* PJ_container_get_or_null(const char* name)
 {
-  if (allContainers.find(name) == allContainers.end())
-    return nullptr;
-  return allContainers.at(name);
+  auto cont = allContainers.find(name);
+  return cont == allContainers.end() ? nullptr : cont->second;
 }
 
 simgrid::instr::Container* PJ_container_get_root()