From ceffb1a0ecaef7407f273d9301f9906ab9f87cd1 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Tue, 30 Oct 2018 16:37:23 -0400 Subject: [PATCH] simplify get_free_slot loops --- malloc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/malloc.c b/malloc.c index 29c14c7..2ab9af6 100644 --- a/malloc.c +++ b/malloc.c @@ -271,11 +271,9 @@ static size_t get_free_slot(struct random_state *rng, size_t slots, struct slab_ masked |= random_split; } - if (masked == ~0UL) { - continue; + if (masked != ~0UL) { + return ffzl(masked) - 1 + i * 64; } - - return ffzl(masked) - 1 + i * 64; } } @@ -285,11 +283,9 @@ static size_t get_free_slot(struct random_state *rng, size_t slots, struct slab_ masked |= get_mask(slots - i * 64); } - if (masked == ~0UL) { - continue; + if (masked != ~0UL) { + return ffzl(masked) - 1 + i * 64; } - - return ffzl(masked) - 1 + i * 64; } fatal_error("no zero bits");