]> git.karo-electronics.de Git - linux-beck.git/commitdiff
fib_trie: only calc for the un-first node
authorbaker.zhang <baker.kernel@gmail.com>
Tue, 8 Oct 2013 03:36:51 +0000 (11:36 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 10 Oct 2013 04:08:07 +0000 (00:08 -0400)
This is a enhancement.

for the first node in fib_trie, newpos is 0, bit is 1.
Only for the leaf or node with unmatched key need calc pos.

Signed-off-by: baker.zhang <baker.kernel@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/fib_trie.c

index 45c74ba039709681e48a219163a74aec737995f5..ec9a9ef4ce50851639cf4cbe8e497390bea371f6 100644 (file)
@@ -1117,12 +1117,8 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
                 *  first tnode need some special handling
                 */
 
-               if (tp)
-                       pos = tp->pos+tp->bits;
-               else
-                       pos = 0;
-
                if (n) {
+                       pos = tp ? tp->pos+tp->bits : 0;
                        newpos = tkey_mismatch(key, pos, n->key);
                        tn = tnode_new(n->key, newpos, 1);
                } else {