Re: [PATCH 29/54] drivers/iio: replace bitmap_weight() with bitmap_weight_{eq,gt} where appropriate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 24 Jan 2022 14:46:43 +0200
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:

> On Sun, Jan 23, 2022 at 10:39:00AM -0800, Yury Norov wrote:
> > drivers/iio calls bitmap_weight() to compare the weight of bitmap with
> > a given number. We can do it more efficiently with bitmap_weight_{eq, gt}
> > because conditional bitmap_weight may stop traversing the bitmap earlier,
> > as soon as condition is met.  
> 
> ...
> 
> >  		int i, j;
> >  
> >  		for (i = 0, j = 0;
> > -		     i < bitmap_weight(indio_dev->active_scan_mask,
> > -				       indio_dev->masklength);
> > +		     bitmap_weight_gt(indio_dev->active_scan_mask,
> > +				       indio_dev->masklength, i);
> >  		     i++, j++) {
> >  			j = find_next_bit(indio_dev->active_scan_mask,
> >  					  indio_dev->masklength, j);  
> 
> This smells like room for improvement. Have you checked this deeply?
> 

I have no idea what I was smoking that day.
It was near 10 years ago, so I'll blame my younger self ;)

Jonathan



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux