simplify get_free_slot loops

pull/65/head
Daniel Micay 2018-10-30 16:37:23 -04:00
parent a02f4ebb19
commit ceffb1a0ec
1 changed files with 4 additions and 8 deletions

View File

@ -271,13 +271,11 @@ static size_t get_free_slot(struct random_state *rng, size_t slots, struct slab_
masked |= random_split; masked |= random_split;
} }
if (masked == ~0UL) { if (masked != ~0UL) {
continue;
}
return ffzl(masked) - 1 + i * 64; return ffzl(masked) - 1 + i * 64;
} }
} }
}
for (unsigned i = 0; i <= (slots - 1) / 64; i++) { for (unsigned i = 0; i <= (slots - 1) / 64; i++) {
u64 masked = metadata->bitmap[i]; u64 masked = metadata->bitmap[i];
@ -285,12 +283,10 @@ static size_t get_free_slot(struct random_state *rng, size_t slots, struct slab_
masked |= get_mask(slots - i * 64); masked |= get_mask(slots - i * 64);
} }
if (masked == ~0UL) { if (masked != ~0UL) {
continue;
}
return ffzl(masked) - 1 + i * 64; return ffzl(masked) - 1 + i * 64;
} }
}
fatal_error("no zero bits"); fatal_error("no zero bits");
} }