From 981adf483791d6145cc028bf18dbdb23a88eaaac Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 8 Jul 2010 12:16:16 +0000 Subject: [PATCH] Minor optimalization of _test_word. Skip ffs() if (test >> bit) is 0. --- libdm/datastruct/bitset.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdm/datastruct/bitset.c b/libdm/datastruct/bitset.c index 9b8aff933..563f684e15 100644 --- a/libdm/datastruct/bitset.c +++ b/libdm/datastruct/bitset.c @@ -69,9 +69,9 @@ void dm_bit_union(dm_bitset_t out, dm_bitset_t in1, dm_bitset_t in2) static int _test_word(uint32_t test, int bit) { - int next_set_bit; + uint32_t tb = test >> bit; - return ((next_set_bit = ffs(test >> bit)) ? next_set_bit + bit - 1 : -1); + return (tb ? ffs(tb) + bit - 1 : -1); } int dm_bit_get_next(dm_bitset_t bs, int last_bit)