lkml.org 
[lkml]   [2015]   [Mar]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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(...);

?



\
 
 \ /
  Last update: 2015-03-25 00:01    [W:0.059 / U:0.156 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site