summaryrefslogtreecommitdiff
path: root/bgpd/bgp_aspath.c
diff options
context:
space:
mode:
authorAndrew J. Schorr <ajschorr@alumni.princeton.edu>2007-04-15 19:17:24 +0000
committerAndrew J. Schorr <ajschorr@alumni.princeton.edu>2007-04-15 19:17:24 +0000
commit93c1749c828cf750fbcc850730b9f2a872e38325 (patch)
tree05800e33ebd68d5e6a2629d20ba54ad4db0aaa7c /bgpd/bgp_aspath.c
parent6dfa827b7be871fc7301d4db04a99b509c9fd7aa (diff)
[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 *