Skip to contentSkip to conversation

fib_trie: only calc for the un-first node

PATCH In review [email protected] 2 participants 2 messages Oct 8, 2013 – Oct 10, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fib_trie: only calc for the un-first node

From: "baker.zhang" <[email protected]>

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.

---
 net/ipv4/fib_trie.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
net/ipv4/fib_trie.c +1 -5
index 45c74ba..ec9a9ef 100644
@@ -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 {
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw

From: [email protected]
Date: Tue, 8 Oct 2013 11:36:51 +0800

Quoted 8 lines

From: "baker.zhang" <[email protected]>

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.

The compiler is probably doing this transformation all by itself, but applied anyways, thanks.