]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: Optimize the loop for xfs_bitmap_empty
authorJia He <hejianet@gmail.com>
Mon, 15 Feb 2016 01:12:38 +0000 (12:12 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 15 Feb 2016 01:12:38 +0000 (12:12 +1100)
Source kernel commit 1d4292bfdc77f4f7c520064be15d0c46bd025fd2

If there is any non zero bit in a long bitmap, it can jump out of the
loop and finish the function as soon as possible.

Signed-off-by: Jia He <hejianet@gmail.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
libxfs/xfs_bit.c

index 8b5b81c21d6901d3aacf233b8ae1f7f8cad47db5..041557aa6f586fe27ad21169889b8e09cdf553e2 100644 (file)
@@ -32,13 +32,13 @@ int
 xfs_bitmap_empty(uint *map, uint size)
 {
        uint i;
-       uint ret = 0;
 
        for (i = 0; i < size; i++) {
-               ret |= map[i];
+               if (map[i] != 0)
+                       return 0;
        }
 
-       return (ret == 0);
+       return 1;
 }
 
 /*