From: igorm@etf.rs
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, Igor Maravic <igorm@etf.rs>
Subject: [PATCH net-next] net: ipv4: optimize tkey_mismatch
Date: Tue, 28 Aug 2012 10:52:18 +0200 [thread overview]
Message-ID: <1346143938-17167-2-git-send-email-igorm@etf.rs> (raw)
In-Reply-To: <1346143938-17167-1-git-send-email-igorm@etf.rs>
From: Igor Maravic <igorm@etf.rs>
Optimize tkey_mismatch function by using __fls function.
Signed-off-by: Igor Maravic <igorm@etf.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
next prev parent reply other threads:[~2012-08-28 8:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-28 8:52 [PATCH net-next] net: ipv4: Optimize check_leaf function igorm
2012-08-28 8:52 ` igorm [this message]
2012-08-28 18:56 ` [PATCH net-next] net: ipv4: optimize tkey_mismatch David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1346143938-17167-2-git-send-email-igorm@etf.rs \
--to=igorm@etf.rs \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox