[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1346143938-17167-2-git-send-email-igorm@etf.rs>
Date: Tue, 28 Aug 2012 10:52:18 +0200
From: igorm@....rs
To: netdev@...r.kernel.org
Cc: davem@...emloft.net, Igor Maravic <igorm@....rs>
Subject: [PATCH net-next] net: ipv4: optimize tkey_mismatch
From: Igor Maravic <igorm@....rs>
Optimize tkey_mismatch function by using __fls function.
Signed-off-by: Igor Maravic <igorm@....rs>
---
net/ipv4/fib_trie.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index ec45621..b4b126c 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -265,14 +265,8 @@ static inline int tkey_sub_equals(t_key a, int offset, int bits, t_key b)
static inline int tkey_mismatch(t_key a, int offset, t_key b)
{
- t_key diff = a ^ b;
- int i = offset;
-
- if (!diff)
- return 0;
- while ((diff << i) >> (KEYLENGTH-1) == 0)
- i++;
- return i;
+ t_key diff = (a ^ b) & (~((t_key)0) << offset >> offset);
+ return diff ? (KEYLENGTH - __fls(diff) - 1) : 0;
}
/*
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists