[PATCH] libxfs: Optimize the loop for xfs_bitmap_empty

Jia He hejianet at gmail.com
Mon Nov 9 08:31:22 CST 2015


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

Signed-off-by: Jia He <hejianet at gmail.com>
Cc: Dave Chinner <david at fromorbit.com> 
Cc: Brian Foster <bfoster at redhat.com> 
---
 fs/xfs/libxfs/xfs_bit.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/xfs/libxfs/xfs_bit.c b/fs/xfs/libxfs/xfs_bit.c
index 0e8885a..84614b0 100644
--- a/fs/xfs/libxfs/xfs_bit.c
+++ b/fs/xfs/libxfs/xfs_bit.c
@@ -36,6 +36,8 @@ xfs_bitmap_empty(uint *map, uint size)
 
 	for (i = 0; i < size; i++) {
 		ret |= map[i];
+		if (ret != 0)
+			return 0;
 	}
 
 	return (ret == 0);
-- 
2.5.0



More information about the xfs mailing list