[PATCH] xfs: improve xfs_bitmap_empty()

Jeff Liu jeff.liu at oracle.com
Fri Jan 31 08:13:37 CST 2014


From: Jie Liu <jeff.liu at oracle.com>

There is no need to travel through the whole bitmap items to verify
if the bitmap array is empty or not, instead, just return 0 directly
if an item is detected in bitmap array.

Signed-off-by: Jie Liu <jeff.liu at oracle.com>
---
 fs/xfs/xfs_bit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_bit.c b/fs/xfs/xfs_bit.c
index 0e8885a..ae0acc2 100644
--- a/fs/xfs/xfs_bit.c
+++ b/fs/xfs/xfs_bit.c
@@ -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])
+			return 0;
 	}
 
-	return (ret == 0);
+	return 1;
 }
 
 /*
-- 
1.8.3.2



More information about the xfs mailing list