Re: [PATCH] libxfs: Optimize the loop for xfs_bitmap_empty

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi Brian
Thanks, I will resend the patch V2

B.R.
Justin

在 11/10/15 8:54 PM, Brian Foster 写道:
On Mon, Nov 09, 2015 at 10:31:22PM +0800, Jia He wrote:
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@xxxxxxxxx>
Cc: Dave Chinner <david@xxxxxxxxxxxxx>
Cc: Brian Foster <bfoster@xxxxxxxxxx>
---
  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;
  	}
Seems Ok to me, but if we're going to do this, why not just kill ret
entirely? For example, check 'if (map[i] != 0) return 0;' in the loop
and unconditionally return 1 if we make it to the end.

Brian

  	return (ret == 0);
--
2.5.0

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs


_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs




[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux