Message ID | 1346143938-17167-2-git-send-email-igorm@etf.rs |
---|---|
State | Rejected, archived |
Delegated to: | David Miller |
Headers | show |
From: igorm@etf.rs Date: Tue, 28 Aug 2012 10:52:18 +0200 > From: Igor Maravic <igorm@etf.rs> > > Optimize tkey_mismatch function by using __fls function. > > Signed-off-by: Igor Maravic <igorm@etf.rs> This will actually run slower on architectures like sparc that don't have special instructions for __fls. Your TOS "optimization" isn't very useful either since having TOS routes is very rare. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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; } /*