mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 14:38:13 +02:00
[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:
parent
039437c9cf
commit
4218699642
1 changed files with 1 additions and 10 deletions
|
|
@ -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 *
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue