Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Constify a parameter, fix name for another, and simplify code.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 15 Oct 2020 09:41:28 +0000 (11:41 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 15 Oct 2020 09:44:31 +0000 (11:44 +0200)
include/simgrid/kernel/routing/RoutedZone.hpp
src/kernel/routing/RoutedZone.cpp

index 877d5cc..6a2e142 100644 (file)
@@ -57,12 +57,12 @@ public:
 
 protected:
   RouteCreationArgs* new_extended_route(RoutingMode hierarchy, NetPoint* gw_src, NetPoint* gw_dst,
-                                        std::vector<resource::LinkImpl*>& link_list, bool change_order);
+                                        const std::vector<resource::LinkImpl*>& link_list, bool preserve_order);
   XBT_ATTRIB_DEPRECATED_v330("Please drop 2nd, 3rd and 7th parameters") virtual RouteCreationArgs* new_extended_route(
       RoutingMode hierarchy, NetPoint* /* src */, NetPoint* /* dst */, NetPoint* gw_src, NetPoint* gw_dst,
-      std::vector<resource::LinkImpl*>& link_list, bool /* symmetrical */, bool change_order)
+      std::vector<resource::LinkImpl*>& link_list, bool /* symmetrical */, bool preserve_order)
   {
-    return new_extended_route(hierarchy, gw_src, gw_dst, link_list, change_order);
+    return new_extended_route(hierarchy, gw_src, gw_dst, link_list, preserve_order);
   }
   void get_route_check_params(NetPoint* src, NetPoint* dst) const;
   void add_route_check_params(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
index 3d1d214..25ad1a1 100644 (file)
@@ -116,7 +116,8 @@ void RoutedZone::get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt
 /* ************************* GENERIC AUX FUNCTIONS ************************** */
 /* change a route containing link names into a route containing link entities */
 RouteCreationArgs* RoutedZone::new_extended_route(RoutingMode hierarchy, NetPoint* gw_src, NetPoint* gw_dst,
-                                                  std::vector<resource::LinkImpl*>& link_list, bool change_order)
+                                                  const std::vector<resource::LinkImpl*>& link_list,
+                                                  bool preserve_order)
 {
   auto* result = new RouteCreationArgs();
 
@@ -130,12 +131,10 @@ RouteCreationArgs* RoutedZone::new_extended_route(RoutingMode hierarchy, NetPoin
     result->gw_dst = gw_dst;
   }
 
-  for (auto const& link : link_list) {
-    if (change_order)
-      result->link_list.push_back(link);
-    else
-      result->link_list.insert(result->link_list.begin(), link);
-  }
+  if (preserve_order)
+    result->link_list = link_list;
+  else
+    result->link_list.assign(link_list.rbegin(), link_list.rend()); // reversed
   result->link_list.shrink_to_fit();
 
   return result;