From b045e3382b1893d6b1e952d451eab103870c704e Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 15 Oct 2020 11:41:28 +0200 Subject: [PATCH] Constify a parameter, fix name for another, and simplify code. --- include/simgrid/kernel/routing/RoutedZone.hpp | 6 +++--- src/kernel/routing/RoutedZone.cpp | 13 ++++++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/simgrid/kernel/routing/RoutedZone.hpp b/include/simgrid/kernel/routing/RoutedZone.hpp index 877d5cc59a..6a2e142ebc 100644 --- a/include/simgrid/kernel/routing/RoutedZone.hpp +++ b/include/simgrid/kernel/routing/RoutedZone.hpp @@ -57,12 +57,12 @@ public: protected: RouteCreationArgs* new_extended_route(RoutingMode hierarchy, NetPoint* gw_src, NetPoint* gw_dst, - std::vector& link_list, bool change_order); + const std::vector& 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& link_list, bool /* symmetrical */, bool change_order) + std::vector& 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, diff --git a/src/kernel/routing/RoutedZone.cpp b/src/kernel/routing/RoutedZone.cpp index 3d1d214192..25ad1a11a2 100644 --- a/src/kernel/routing/RoutedZone.cpp +++ b/src/kernel/routing/RoutedZone.cpp @@ -116,7 +116,8 @@ void RoutedZone::get_graph(const s_xbt_graph_t* graph, std::map& link_list, bool change_order) + const std::vector& 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; -- 2.20.1