[skiplist] Use ffs()

Use ffs() [find-first-set-bit] instead of open-coding, which is about 25%
faster on my test machine.
This commit is contained in:
Chris Wilson 2008-11-26 11:54:29 +00:00
parent 039437c9cf
commit 4218699642

View file

@ -91,20 +91,11 @@ _cairo_skip_list_fini (cairo_skip_list_t *list)
static int
random_level (void)
{
int level = 0;
/* tricky bit -- each bit is '1' 75% of the time.
* This works because we only use the lower MAX_LEVEL
* bits, and MAX_LEVEL < 16 */
uint32_t bits = hars_petruska_f54_1_random ();
bits |= bits >> 16;
while (++level < MAX_LEVEL)
{
if (bits & 1)
break;
bits >>= 1;
}
return level;
return ffs (-(1<<MAX_LEVEL) | bits | bits >> 16);
}
static void *