Skip to content

Commit

Permalink
fib: use __fls() on non null argument
Browse files Browse the repository at this point in the history
__fls(x) is a bit faster than fls(x), granted we know x is non null.

As Ben Hutchings pointed out, fls(x) = __fls(x) + 1

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Aug 7, 2012
1 parent 425f09a commit 79cda75
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/ipv4/fib_trie.c
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,8 @@ int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp,
* state.directly.
*/
if (pref_mismatch) {
int mp = KEYLENGTH - fls(pref_mismatch);
/* fls(x) = __fls(x) + 1 */
int mp = KEYLENGTH - __fls(pref_mismatch) - 1;

if (tkey_extract_bits(cn->key, mp, cn->pos - mp) != 0)
goto backtrace;
Expand Down

0 comments on commit 79cda75

Please sign in to comment.