diff options
author | baker.zhang <baker.kernel@gmail.com> | 2013-10-07 23:36:51 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-10-10 00:08:07 -0400 |
commit | 4c60f1d67fae632743df9324301e3cb2682f54d4 (patch) | |
tree | 4fc98e10c4297e290f559024bf9e4a18f2c0d3f3 /net/ipv4/fib_trie.c | |
parent | 5c70ef85a2f26d8a0e1aaa7b4cbfff44fda36585 (diff) |
fib_trie: only calc for the un-first node
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>
Diffstat (limited to 'net/ipv4/fib_trie.c')
-rw-r--r-- | net/ipv4/fib_trie.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 45c74ba03970..ec9a9ef4ce50 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
@@ -1117,12 +1117,8 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen) | |||
1117 | * first tnode need some special handling | 1117 | * first tnode need some special handling |
1118 | */ | 1118 | */ |
1119 | 1119 | ||
1120 | if (tp) | ||
1121 | pos = tp->pos+tp->bits; | ||
1122 | else | ||
1123 | pos = 0; | ||
1124 | |||
1125 | if (n) { | 1120 | if (n) { |
1121 | pos = tp ? tp->pos+tp->bits : 0; | ||
1126 | newpos = tkey_mismatch(key, pos, n->key); | 1122 | newpos = tkey_mismatch(key, pos, n->key); |
1127 | tn = tnode_new(n->key, newpos, 1); | 1123 | tn = tnode_new(n->key, newpos, 1); |
1128 | } else { | 1124 | } else { |