]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: prefix.c nano-optimisation
authorPaul Jakma <paul@quagga.net>
Sun, 24 Jan 2010 21:41:02 +0000 (21:41 +0000)
committerPaul Jakma <paul@quagga.net>
Wed, 8 Dec 2010 17:05:11 +0000 (17:05 +0000)
* lib/prefix.c: (prefix_match) nano-optimisation, let it return early
  without copying pointers.

lib/prefix.c

index 7dc866d11675a01b50257f6ae441a48dfd5ca237..61a278cae985ad36c037b5718c5efeaab6dc8ce0 100644 (file)
@@ -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;