Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce scope for variables (sonar).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 11 Apr 2023 13:26:28 +0000 (15:26 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 11 Apr 2023 13:26:28 +0000 (15:26 +0200)
src/dag/loaders.cpp
src/mc/api/strategy/WaitStrategy.hpp
src/sthread/ObjectAccess.cpp

index d4d99a2..465e0af 100644 (file)
@@ -129,12 +129,8 @@ std::vector<ActivityPtr> create_DAG_from_json(const std::string& filename)
     }
 
     dag.push_back(current);
-    for (auto const& parent: task["parents"]) {
-      auto it = successors.find(parent);
-      if (it == successors.end())
-        successors[parent] = {};
+    for (auto const& parent : task["parents"])
       successors[parent].push_back(current);
-    }
   }
   // Assign successors
   for (auto const& [parent, successors_list] : successors)
index 39a78c7..ae54912 100644 (file)
@@ -58,9 +58,8 @@ public:
 
   void consider_best() override
   {
-    const auto& [aid, _] = this->next_transition();
-    auto actor           = actors_to_run_.find(aid);
-    if (actor != actors_to_run_.end()) {
+    aid_t aid = next_transition().first;
+    if (auto actor = actors_to_run_.find(aid); actor != actors_to_run_.end()) {
       actor->second.mark_todo();
       return;
     }
index 6584c7f..6e38668 100644 (file)
@@ -66,11 +66,10 @@ static ObjectOwner* get_owner(void* object)
 {
   if (owners.empty())
     std::atexit(clean_owners);
-  auto it = owners.find(object);
-  if (it != owners.end())
+  if (auto it = owners.find(object); it != owners.end())
     return it->second;
   auto* o = new ObjectOwner(nullptr);
-  owners.insert({object, o});
+  owners.emplace(object, o);
   return o;
 }