Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 4 Jan 2017 23:16:02 +0000 (00:16 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 4 Jan 2017 23:16:02 +0000 (00:16 +0100)
src/kernel/routing/FullZone.cpp
src/kernel/routing/RoutedZone.cpp
src/kernel/routing/RoutedZone.hpp

index 93210c6..d9b0bab 100644 (file)
@@ -20,20 +20,16 @@ FullZone::FullZone(NetZone* father, const char* name) : RoutedZone(father, name)
 
 void FullZone::seal()
 {
-  int i;
-  sg_platf_route_cbarg_t e_route;
-
-  /* set utils vars */
   int table_size = static_cast<int>(vertices_.size());
 
-  /* Create table if necessary */
+  /* Create table if needed */
   if (!routingTable_)
     routingTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
 
   /* Add the loopback if needed */
   if (surf_network_model->loopback_ && hierarchy_ == RoutingMode::base) {
-    for (i = 0; i < table_size; i++) {
-      e_route = TO_ROUTE_FULL(i, i);
+    for (int i = 0; i < table_size; i++) {
+      sg_platf_route_cbarg_t e_route = TO_ROUTE_FULL(i, i);
       if (!e_route) {
         e_route            = xbt_new0(s_sg_platf_route_cbarg_t, 1);
         e_route->gw_src    = nullptr;
@@ -102,8 +98,7 @@ void FullZone::addRoute(sg_platf_route_cbarg_t route)
                dst->cname());
 
   /* Add the route to the base */
-  TO_ROUTE_FULL(src->id(), dst->id()) = newExtendedRoute(hierarchy_, route, 1);
-  TO_ROUTE_FULL(src->id(), dst->id())->link_list->shrink_to_fit();
+  TO_ROUTE_FULL(src->id(), dst->id()) = newExtendedRoute(hierarchy_, route, true);
 
   if (route->symmetrical == true && src != dst) {
     if (route->gw_dst && route->gw_src) {
@@ -121,8 +116,7 @@ void FullZone::addRoute(sg_platf_route_cbarg_t route)
                  "The route between %s and %s already exists. You should not declare the reverse path as symmetrical.",
                  dst->cname(), src->cname());
 
-    TO_ROUTE_FULL(dst->id(), src->id()) = newExtendedRoute(hierarchy_, route, 0);
-    TO_ROUTE_FULL(dst->id(), src->id())->link_list->shrink_to_fit();
+    TO_ROUTE_FULL(dst->id(), src->id()) = newExtendedRoute(hierarchy_, route, false);
   }
 }
 }
index b559691..5209a95 100644 (file)
@@ -129,7 +129,7 @@ void RoutedZone::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 /* ************************* GENERIC AUX FUNCTIONS ************************** */
 /* change a route containing link names into a route containing link entities */
 sg_platf_route_cbarg_t RoutedZone::newExtendedRoute(RoutingMode hierarchy, sg_platf_route_cbarg_t routearg,
-                                                    int change_order)
+                                                    bool change_order)
 {
   sg_platf_route_cbarg_t result;
 
@@ -152,6 +152,7 @@ sg_platf_route_cbarg_t RoutedZone::newExtendedRoute(RoutingMode hierarchy, sg_pl
     else
       result->link_list->insert(result->link_list->begin(), link);
   }
+  result->link_list->shrink_to_fit();
 
   return result;
 }
index 18c122b..c90df9d 100644 (file)
@@ -54,7 +54,7 @@ public:
 
   void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) override;
   virtual sg_platf_route_cbarg_t newExtendedRoute(RoutingMode hierarchy, sg_platf_route_cbarg_t routearg,
-                                                  int change_order);
+                                                  bool change_order);
 
 protected:
   void getRouteCheckParams(NetCard* src, NetCard* dst);