Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Prefer std algorithms.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 1 Jun 2021 13:26:10 +0000 (15:26 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 1 Jun 2021 13:55:03 +0000 (15:55 +0200)
src/kernel/routing/NetZoneImpl.cpp
src/mc/remote/AppSide.cpp

index 6d59bda..72c8f19 100644 (file)
@@ -558,16 +558,12 @@ const NetZoneImpl* NetZoneImpl::get_netzone_recursive(const NetPoint* netpoint)
 bool NetZoneImpl::is_component_recursive(const NetPoint* netpoint) const
 {
   /* check direct components */
-  for (const auto* elem : vertices_) {
-    if (elem == netpoint)
-      return true;
-  }
+  if (std::any_of(begin(vertices_), end(vertices_), [netpoint](const auto* elem) { return elem == netpoint; }))
+    return true;
+
   /* check childrens */
-  for (const auto* children : children_) {
-    if (children->is_component_recursive(netpoint))
-      return true;
-  }
-  return false;
+  return std::any_of(begin(children_), end(children_),
+                     [netpoint](const auto* child) { return child->is_component_recursive(netpoint); });
 }
 } // namespace routing
 } // namespace kernel
index 27b560d..8d90899 100644 (file)
@@ -85,15 +85,9 @@ AppSide* AppSide::initialize()
 void AppSide::handle_deadlock_check(const s_mc_message_t*) const
 {
   const auto& actor_list = kernel::EngineImpl::get_instance()->get_actor_list();
-  bool deadlock = false;
-  if (not actor_list.empty()) {
-    deadlock = true;
-    for (auto const& kv : actor_list)
-      if (mc::actor_is_enabled(kv.second)) {
-        deadlock = false;
-        break;
-      }
-  }
+  bool deadlock = not actor_list.empty() && std::none_of(begin(actor_list), end(actor_list), [](const auto& kv) {
+    return mc::actor_is_enabled(kv.second);
+  });
 
   // Send result:
   s_mc_message_int_t answer{MessageType::DEADLOCK_CHECK_REPLY, deadlock};