diff options
author | Paul Jakma <paul@quagga.net> | 2010-01-24 21:41:02 +0000 |
---|---|---|
committer | Paul Jakma <paul@quagga.net> | 2010-12-08 17:05:11 +0000 |
commit | d358344759d85a965bbd767f4a994695f99b842e (patch) | |
tree | 47fb2bd213c0e4c5f23e0066aea5b96c747d27b4 /lib | |
parent | 3322055b392f20f4b97122a8034e479719e4b86d (diff) |
lib: prefix.c nano-optimisation
* lib/prefix.c: (prefix_match) nano-optimisation, let it return early
without copying pointers.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/prefix.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/prefix.c b/lib/prefix.c index 7dc866d1..61a278ca 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -70,15 +70,16 @@ prefix_match (const struct prefix *n, const struct prefix *p) { int offset; int shift; - - /* Set both prefix's head pointer. */ - const u_char *np = (const u_char *)&n->u.prefix; - const u_char *pp = (const u_char *)&p->u.prefix; + const u_char *np, *pp; /* If n's prefix is longer than p's one return 0. */ if (n->prefixlen > p->prefixlen) return 0; + /* Set both prefix's head pointer. */ + np = (const u_char *)&n->u.prefix; + pp = (const u_char *)&p->u.prefix; + offset = n->prefixlen / PNBBY; shift = n->prefixlen % PNBBY; |