Messages in this thread | | | Date | Tue, 24 Mar 2015 15:53:03 -0700 | From | Andrew Morton <> | Subject | Re: [PATCH] lib: bitmap_[empty,full]: remove code duplication |
| |
On Mon, 16 Mar 2015 20:56:39 +0300 Yury Norov <yury.norov@gmail.com> wrote:
> Function 'bitmap_empty' has it's own implementation. > But it's clearly as simple as: > "find_first_bit(src, nbits) == nbits" > The same is true for 'bitmap_full'. > > Underscored versions of 'bitmap_[empty,full]' are not > needed anymore and so removed too. > > Boot-tested on Core i7-2630QM. > > --- a/include/linux/bitmap.h > +++ b/include/linux/bitmap.h > @@ -285,18 +285,12 @@ static inline int bitmap_subset(const unsigned long *src1, > > static inline int bitmap_empty(const unsigned long *src, unsigned nbits) > { > - if (small_const_nbits(nbits)) > - return ! (*src & BITMAP_LAST_WORD_MASK(nbits)); > - else > - return __bitmap_empty(src, nbits); > + return find_first_bit(src, nbits) == nbits; > }
But we lost the small_const_nbits() optimization, and that will be a common case.
Would it be better to do
if (small_const_nbits(...)) ... else find_first_bit(...);
?
| |