mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-06 14:05:39 +00:00
lib/find: optimize find_*_bit_wrap
When an offset is 0, there's no need to search a bitmap from the beginning after the 1st search failed, because each bit has already been tested. Signed-off-by: Yury Norov <yury.norov@gmail.com>
This commit is contained in:
parent
92697139b0
commit
27c82f14e6
@ -405,7 +405,7 @@ unsigned long find_next_and_bit_wrap(const unsigned long *addr1,
|
||||
{
|
||||
unsigned long bit = find_next_and_bit(addr1, addr2, size, offset);
|
||||
|
||||
if (bit < size)
|
||||
if (bit < size || offset == 0)
|
||||
return bit;
|
||||
|
||||
bit = find_first_and_bit(addr1, addr2, offset);
|
||||
@ -427,7 +427,7 @@ unsigned long find_next_bit_wrap(const unsigned long *addr,
|
||||
{
|
||||
unsigned long bit = find_next_bit(addr, size, offset);
|
||||
|
||||
if (bit < size)
|
||||
if (bit < size || offset == 0)
|
||||
return bit;
|
||||
|
||||
bit = find_first_bit(addr, offset);
|
||||
|
Loading…
Reference in New Issue
Block a user