summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_aspath.c
diff options
context:
space:
mode:
authorajs <ajs>2007-04-15 19:17:24 +0000
committerajs <ajs>2007-04-15 19:17:24 +0000
commitecbac23d5537ed443aa060adfb150b227515c160 (patch)
tree9422562554ac188710b6051f001b7bed9b80c1b2 /bgpd/bgp_aspath.c
parenta1498c04e7200e5c8857a9fe37fbb8b3d0bbfeb1 (diff)
downloadquagga-ecbac23d5537ed443aa060adfb150b227515c160.tar.bz2
quagga-ecbac23d5537ed443aa060adfb150b227515c160.tar.xz
[bgpd] Minor performance improvement patch
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.
Diffstat (limited to 'bgpd/bgp_aspath.c')
-rw-r--r--bgpd/bgp_aspath.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index 327406fa..1f522d79 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -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 *