summaryrefslogtreecommitdiff
path: root/bgpd/bgp_ecommunity.c
diff options
context:
space:
mode:
authorJorge Boncompte [DTI2] <jorge@dti2.net>2012-05-07 16:52:55 +0000
committerDavid Lamparter <equinox@opensourcerouting.org>2012-05-22 20:25:44 +0200
commitc76275ee960c708408646d8a680b201b27cb9c1a (patch)
tree59daf9a650950d35aa5350270118cd94e4a1fde3 /bgpd/bgp_ecommunity.c
parent6d85b15bbb2fd3c263d5d4b402c88ff348af877b (diff)
bgpd: optimize loops on [e]community_hash_make()
This change reduces loop count. Less jumps. * bgp_community.c: One loop per community. * bgp_ecommunity.c: One loop per ecommunity. Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_ecommunity.c')
-rw-r--r--bgpd/bgp_ecommunity.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c
index 9f4aaa4b..5722425e 100644
--- a/bgpd/bgp_ecommunity.c
+++ b/bgpd/bgp_ecommunity.c
@@ -233,15 +233,22 @@ unsigned int
ecommunity_hash_make (void *arg)
{
const struct ecommunity *ecom = arg;
+ int size = ecom->size * ECOMMUNITY_SIZE;
+ u_int8_t *pnt = ecom->val;
+ unsigned int key = 0;
int c;
- unsigned int key;
- u_int8_t *pnt;
- key = 0;
- pnt = ecom->val;
-
- for (c = 0; c < ecom->size * ECOMMUNITY_SIZE; c++)
- key += pnt[c];
+ for (c = 0; c < size; c += ECOMMUNITY_SIZE)
+ {
+ key += pnt[c];
+ key += pnt[c + 1];
+ key += pnt[c + 2];
+ key += pnt[c + 3];
+ key += pnt[c + 4];
+ key += pnt[c + 5];
+ key += pnt[c + 6];
+ key += pnt[c + 7];
+ }
return key;
}