Skip to content

Commit 27c82f1

Browse files
committed
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>
1 parent 9269713 commit 27c82f1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

include/linux/find.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ unsigned long find_next_and_bit_wrap(const unsigned long *addr1,
405405
{
406406
unsigned long bit = find_next_and_bit(addr1, addr2, size, offset);
407407

408-
if (bit < size)
408+
if (bit < size || offset == 0)
409409
return bit;
410410

411411
bit = find_first_and_bit(addr1, addr2, offset);
@@ -427,7 +427,7 @@ unsigned long find_next_bit_wrap(const unsigned long *addr,
427427
{
428428
unsigned long bit = find_next_bit(addr, size, offset);
429429

430-
if (bit < size)
430+
if (bit < size || offset == 0)
431431
return bit;
432432

433433
bit = find_first_bit(addr, offset);

0 commit comments

Comments
 (0)