Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce scope for temporary variables.
[simgrid.git] / src / kernel / routing / DijkstraZone.cpp
index d47dc4d769e221db2d6f2a9a0ecb167f56030a05..40335edf8a4f4b96bf74124b1ae8ea2583c1befd 100644 (file)
@@ -1,19 +1,19 @@
-/* Copyright (c) 2009-2021. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2009-2022. 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. */
 
-#include "simgrid/kernel/routing/DijkstraZone.hpp"
-#include "simgrid/kernel/routing/NetPoint.hpp"
-#include "src/surf/network_interface.hpp"
-#include "surf/surf.hpp"
-#include "xbt/string.hpp"
+#include <simgrid/kernel/routing/DijkstraZone.hpp>
+#include <simgrid/kernel/routing/NetPoint.hpp>
+#include <xbt/string.hpp>
+
+#include "src/kernel/resource/NetworkModel.hpp"
 
 #include <climits>
 #include <queue>
 #include <vector>
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_dijkstra, surf, "Routing part of surf -- dijkstra routing logic");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ker_routing_dijkstra, ker_routing, "Kernel Dijkstra Routing");
 
 namespace simgrid {
 namespace kernel {
@@ -53,7 +53,7 @@ void DijkstraZone::do_seal()
 
       if (not found) {
         auto* route = new Route();
-        route->link_list_.push_back(get_network_model()->loopback_);
+        route->link_list_.push_back(get_network_model()->loopback_.get());
         xbt_graph_new_edge(route_graph_.get(), node, node, route);
       }
     }
@@ -113,10 +113,10 @@ void DijkstraZone::get_local_route(const NetPoint* src, const NetPoint* dst, Rou
     insert_link_latency(route->link_list_, e_route->link_list_, lat);
   }
 
-  auto elm                             = route_cache_.emplace(src_id, std::vector<unsigned long>());
-  std::vector<unsigned long>& pred_arr = elm.first->second;
+  auto [elm, inserted]                 = route_cache_.try_emplace(src_id);
+  std::vector<unsigned long>& pred_arr = elm->second;
 
-  if (elm.second) { /* new element was inserted (not cached mode, or cache miss) */
+  if (inserted) { /* new element was inserted (not cached mode, or cache miss) */
     unsigned long nr_nodes = xbt_dynar_length(nodes);
     std::vector<unsigned long> cost_arr(nr_nodes); /* link cost from src to other hosts */
     pred_arr.resize(nr_nodes);              /* predecessors in path from src */
@@ -184,7 +184,7 @@ void DijkstraZone::get_local_route(const NetPoint* src, const NetPoint* dst, Rou
 
     if (get_hierarchy() == RoutingMode::recursive && v != dst_node_id &&
         gw_dst->get_name() != prev_gw_src->get_name()) {
-      std::vector<resource::LinkImpl*> e_route_as_to_as;
+      std::vector<resource::StandardLinkImpl*> e_route_as_to_as;
 
       const NetPoint* gw_dst_net_elm      = nullptr;
       const NetPoint* prev_gw_src_net_elm = nullptr;