Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
authorGuillaume Seguin <guillaume.seguin@sophia.inria.fr>
Sat, 05 Sep 2009 16:31:07 -0700
changeset 4758 0f9bcd407aff
parent 4757 1b7c28a1c131
child 4759 a18ac083ec51
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
src/routing/global-routing/global-route-manager-impl.cc
--- a/src/routing/global-routing/global-route-manager-impl.cc	Fri Sep 04 18:02:03 2009 -0700
+++ b/src/routing/global-routing/global-route-manager-impl.cc	Sat Sep 05 16:31:07 2009 -0700
@@ -406,7 +406,8 @@
 GlobalRouteManagerImpl::DeleteGlobalRoutes ()
 {
   NS_LOG_FUNCTION_NOARGS ();
-  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); i++)
+  NodeList::Iterator listEnd = NodeList::End ();
+  for (NodeList::Iterator i = NodeList::Begin (); i != listEnd; i++)
     {
       Ptr<Node> node = *i;
       Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> ();
@@ -453,7 +454,8 @@
 // Walk the list of nodes looking for the GlobalRouter Interface.  Nodes with
 // global router interfaces are, not too surprisingly, our routers.
 //
-  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); i++)
+  NodeList::Iterator listEnd = NodeList::End ();
+  for (NodeList::Iterator i = NodeList::Begin (); i != listEnd; i++)
     {
       Ptr<Node> node = *i;
 
@@ -534,7 +536,8 @@
 //
 // Walk the list of nodes in the system.
 //
-  for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); i++)
+  NodeList::Iterator listEnd = NodeList::End ();
+  for (NodeList::Iterator i = NodeList::Begin (); i != listEnd; i++)
     {
       Ptr<Node> node = *i;
 //
@@ -1351,7 +1354,8 @@
 // the routing information to.
 //
   NodeList::Iterator i = NodeList::Begin (); 
-  for (; i != NodeList::End (); i++)
+  NodeList::Iterator listEnd = NodeList::End ();
+  for (; i != listEnd; i++)
     {
       Ptr<Node> node = *i;
 //
@@ -1516,7 +1520,8 @@
 // the routing information to.
 //
   NodeList::Iterator i = NodeList::Begin (); 
-  for (; i != NodeList::End (); i++)
+  NodeList::Iterator listEnd = NodeList::End ();
+  for (; i != listEnd; i++)
     {
       Ptr<Node> node = *i;
 //
@@ -1637,7 +1642,8 @@
 // building the routing table.
 //
   NodeList::Iterator i = NodeList::Begin (); 
-  for (; i != NodeList::End (); i++)
+  NodeList::Iterator listEnd = NodeList::End ();
+  for (; i != listEnd; i++)
     {
       Ptr<Node> node = *i;
 
@@ -1727,7 +1733,8 @@
 // the routing information to.
 //
   NodeList::Iterator i = NodeList::Begin (); 
-  for (; i != NodeList::End (); i++)
+  NodeList::Iterator listEnd = NodeList::End ();
+  for (; i != listEnd; i++)
     {
       Ptr<Node> node = *i;
 //
@@ -1867,7 +1874,8 @@
 // the routing information to.
 //
   NodeList::Iterator i = NodeList::Begin (); 
-  for (; i != NodeList::End (); i++)
+  NodeList::Iterator listEnd = NodeList::End ();
+  for (; i != listEnd; i++)
     {
       Ptr<Node> node = *i;
 //