]> sourceware.org Git - lvm2.git/commitdiff
Minor optimalization of _test_word.
authorZdenek Kabelac <zkabelac@redhat.com>
Thu, 8 Jul 2010 12:16:16 +0000 (12:16 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Thu, 8 Jul 2010 12:16:16 +0000 (12:16 +0000)
Skip ffs() if  (test >> bit) is 0.

libdm/datastruct/bitset.c

index 9b8aff933c0c6ddc6c4df9c989ad3e11b06b8f0b..563f684e155c8c2fef8f47945a7f4dad93713c11 100644 (file)
@@ -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)
This page took 0.037718 seconds and 5 git commands to generate.