xfs
[Top] [All Lists]

Re: [PATCH] xfs: improve xfs_bitmap_empty()

To: Jeff Liu <jeff.liu@xxxxxxxxxx>, "xfs@xxxxxxxxxxx" <xfs@xxxxxxxxxxx>
Subject: Re: [PATCH] xfs: improve xfs_bitmap_empty()
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Fri, 31 Jan 2014 09:07:41 -0600
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <52EBAF91.10608@xxxxxxxxxx>
References: <52EBAF91.10608@xxxxxxxxxx>
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
On 1/31/14, 8:13 AM, Jeff Liu wrote:
> From: Jie Liu <jeff.liu@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>

Makes sense (and the long loop was my fault, I guess, but it's 
better than it was, see commit 24ad33f!)

Reviewed-by: Eric Sandeen <sandeen@xxxxxxxxxx>

I wonder if something like:

return (find_first_set(map, size) == size);

would be faster (or if it'd be worth it)...?
Probably not.  :)

> ---
>  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;
>  }
>  
>  /*
> 

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