Commit 27c82f14 authored by Yury Norov's avatar Yury Norov

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: default avatarYury Norov <yury.norov@gmail.com>
parent 92697139
...@@ -405,7 +405,7 @@ unsigned long find_next_and_bit_wrap(const unsigned long *addr1, ...@@ -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); unsigned long bit = find_next_and_bit(addr1, addr2, size, offset);
if (bit < size) if (bit < size || offset == 0)
return bit; return bit;
bit = find_first_and_bit(addr1, addr2, offset); bit = find_first_and_bit(addr1, addr2, offset);
...@@ -427,7 +427,7 @@ unsigned long find_next_bit_wrap(const unsigned long *addr, ...@@ -427,7 +427,7 @@ unsigned long find_next_bit_wrap(const unsigned long *addr,
{ {
unsigned long bit = find_next_bit(addr, size, offset); unsigned long bit = find_next_bit(addr, size, offset);
if (bit < size) if (bit < size || offset == 0)
return bit; return bit;
bit = find_first_bit(addr, offset); bit = find_first_bit(addr, offset);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment