xfs
[Top] [All Lists]

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

To: Brian Foster <bfoster@xxxxxxxxxx>
Subject: Re: [PATCH] libxfs: Optimize the loop for xfs_bitmap_empty
From: hejianet <hejianet@xxxxxxxxx>
Date: Wed, 11 Nov 2015 14:37:51 +0800
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=w4xwi+wTj6m5mLUy1zkilI7s2t/xElK4vfxbCkurYCc=; b=IafeHGn0kNuHOD3US8IppGbeiN/NeTSfPZd0O7OLTQ5b4Zb4+mZoysSJjVUKC+OpNY Xy0KVawR+kzUdsj93jqR8d3fPZWziyXQkU7r2boXiKlTBL8UB7N8IYXRyEEAqwEF/nDL SMNMtVl55yheoDSSt5/7j650auVdRW3HlxGh70/rxi+6x4NQ12XPmnyegcr70r4dMmzb kg6jBwAS/Ujlz1yI3ALveB7aB4wDrD4/4JgGH+cxRLCPnjoRd5E+VXlwK5rQrI3i1HbS 74saoyskQS7p2s73RefxXa3m+MDj3sazbMRRT4yQHrQq1nU1zpRmVTYoAZpISdrL48wK kvoQ==
In-reply-to: <20151110125403.GC21670@xxxxxxxxxxxxxxx>
References: <1447079482-10650-1-git-send-email-hejianet@xxxxxxxxx> <20151110125403.GC21670@xxxxxxxxxxxxxxx>
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

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


<Prev in Thread] Current Thread [Next in Thread>