]> git.puffer.fish Git - mirror/frr.git/commitdiff
[bgpd] Minor performance improvement patch
authorAndrew J. Schorr <ajschorr@alumni.princeton.edu>
Sun, 15 Apr 2007 19:17:24 +0000 (19:17 +0000)
committerAndrew J. Schorr <ajschorr@alumni.princeton.edu>
Sun, 15 Apr 2007 19:17:24 +0000 (19:17 +0000)
2007-04-15 Sebastien Tandel <sebastien@tandel.be>

* bgp_aspath.c: (aspath_as_add, aspath_segment_add) Minor performance
  optimization: while loop should test one pointer instead of two.

bgpd/ChangeLog
bgpd/bgp_aspath.c

index 4d6f1ef9d1c69217b5a3f3acfb51280ec51d60cc..37ca2fb40b50102c66a19e7f14f30bb9cc79cc27 100644 (file)
@@ -1,3 +1,8 @@
+2007-04-15 Sebastien Tandel <sebastien@tandel.be>
+
+       * bgp_aspath.c: (aspath_as_add, aspath_segment_add) Minor performance
+         optimization: while loop should test one pointer instead of two.
+
 2007-04-08 Paul Jakma <paul.jakma@sun.com>
 
        * bgp_route.c: (general) Same bug as fixed on 2006-11-28 by ajs for
index 327406fae98e4d73f688cba136f3a8b4e2a5bece..1f522d79ca4ac6edd843f26efcde7bb9d831034a 100644 (file)
@@ -1243,13 +1243,13 @@ aspath_as_add (struct aspath *as, as_t asno)
 {
   struct assegment *seg = as->segments;
 
-  /* Last segment search procedure. */
-  while (seg && seg->next)
-    seg = seg->next;
-  
   if (!seg)
     return;
   
+  /* Last segment search procedure. */
+  while (seg->next)
+    seg = seg->next;
+
   assegment_append_asns (seg, &asno, 1);
 }
 
@@ -1260,13 +1260,14 @@ aspath_segment_add (struct aspath *as, int type)
   struct assegment *seg = as->segments;
   struct assegment *new = assegment_new (type, 0);
 
-  while (seg && seg->next)
-    seg = seg->next;
-  
-  if (seg == NULL)
-    as->segments = new;
+  if (seg)
+    {
+      while (seg->next)
+       seg = seg->next;
+      seg->next = new;
+    }
   else
-    seg->next = new;
+    as->segments = new;
 }
 
 struct aspath *