Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4c60f1d6 authored by baker.zhang's avatar baker.zhang Committed by David S. Miller
Browse files

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: default avatarbaker.zhang <baker.kernel@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5c70ef85
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -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 {