lib/axmap: Simplify axmap_set_fn()
authorBart Van Assche <bart.vanassche@wdc.com>
Wed, 22 Aug 2018 17:43:46 +0000 (10:43 -0700)
committerBart Van Assche <bvanassche@acm.org>
Thu, 23 Aug 2018 01:59:24 +0000 (18:59 -0700)
Instead of handling ffz(~overlap) == bit as a special case, handle
this case in the same way as ffz(~overlap) != bit. This patch does
not change any functionality but removes one if-instruction from the
hot path.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
lib/axmap.c

index 781a103..336d704 100644 (file)
@@ -235,18 +235,12 @@ static bool axmap_set_fn(struct axmap_level *al, unsigned long offset,
         */
        overlap = al->map[offset] & mask;
        if (overlap == mask) {
-done:
                data->set_bits = 0;
                return true;
        }
 
        if (overlap) {
-               const int __bit = ffz(~overlap);
-
-               nr_bits = __bit - bit;
-               if (!nr_bits)
-                       goto done;
-
+               nr_bits = ffz(~overlap) - bit;
                mask = bit_masks[nr_bits] << bit;
        }