Subject: Re: diff to speed up fdalloc using two-level bitmaps
To: <>
From: David Laight <david@l8s.co.uk>
List: tech-perform
Date: 10/29/2003 09:14:08
> It's much easier to find the last (that is, least significant) set
> or clear bit.  You can sometimes change the algorithm or the data
> representation to suit.
> 
>     unsigned int find_last_set(unsigned int x)
>     {
> 	return (x & -x);
>     }
> 
>     unsigned int find_last_clear(unsigned int x)
>     {
> 	return (~x & (x+1));
>     }

Unfortunately you still need to do the log2(x)....

	David

-- 
David Laight: david@l8s.co.uk