diff mbox

[OPW,kernel,1/2] fs: btrfs: Use `||` in ref_for_same_block

Message ID d0efdb279294e0732810f385e4cb467d093fc1a9.1382349648.git.rashika.kheria@gmail.com
State New, archived
Headers show

Commit Message

Rashika Oct. 21, 2013, 10:02 a.m. UTC
This patch uses '||' operator to club together the if conditions that
have the same body.

Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
---
 fs/btrfs/backref.c |   17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

Comments

Josh Triplett Oct. 21, 2013, 7:50 p.m. UTC | #1
On Mon, Oct 21, 2013 at 03:32:15PM +0530, Rashika Kheria wrote:
> This patch uses '||' operator to club together the if conditions that
> have the same body.
> 
> Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>

Reviewed-by: Josh Triplett <josh@joshtriplett.org>

>  fs/btrfs/backref.c |   17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
> index 0552a59..c63aa34c 100644
> --- a/fs/btrfs/backref.c
> +++ b/fs/btrfs/backref.c
> @@ -410,17 +410,12 @@ out:
>  static inline int ref_for_same_block(struct __prelim_ref *ref1,
>  				     struct __prelim_ref *ref2)
>  {
> -	if (ref1->level != ref2->level)
> -		return 0;
> -	if (ref1->root_id != ref2->root_id)
> -		return 0;
> -	if (ref1->key_for_search.type != ref2->key_for_search.type)
> -		return 0;
> -	if (ref1->key_for_search.objectid != ref2->key_for_search.objectid)
> -		return 0;
> -	if (ref1->key_for_search.offset != ref2->key_for_search.offset)
> -		return 0;
> -	if (ref1->parent != ref2->parent)
> +	if ((ref1->level != ref2->level) ||
> +	    (ref1->root_id != ref2->root_id) ||
> +	    (ref1->key_for_search.type != ref2->key_for_search.type) ||
> +	    (ref1->key_for_search.objectid != ref2->key_for_search.objectid) ||
> +	    (ref1->key_for_search.offset != ref2->key_for_search.offset) ||
> +	    (ref1->parent != ref2->parent))
>  		return 0;
>  
>  	return 1;
> -- 
> 1.7.9.5
> 
> -- 
> You received this message because you are subscribed to the Google Groups "opw-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to opw-kernel+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Rusty Russell Oct. 21, 2013, 11:31 p.m. UTC | #2
Rashika Kheria <rashika.kheria@gmail.com> writes:
> This patch uses '||' operator to club together the if conditions that
> have the same body.
>
> Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>

Hi Rashika,

        I don't like to be a curmudgeon, but I prefer the original.  The
compiler certainly won't care, but I think this change is gratuitous.

Zach might have a different opinion, of course (and the other patch is
great).

Cheers,
Rusty.

> ---
>  fs/btrfs/backref.c |   17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 deletions(-)
>
> diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
> index 0552a59..c63aa34c 100644
> --- a/fs/btrfs/backref.c
> +++ b/fs/btrfs/backref.c
> @@ -410,17 +410,12 @@ out:
>  static inline int ref_for_same_block(struct __prelim_ref *ref1,
>  				     struct __prelim_ref *ref2)
>  {
> -	if (ref1->level != ref2->level)
> -		return 0;
> -	if (ref1->root_id != ref2->root_id)
> -		return 0;
> -	if (ref1->key_for_search.type != ref2->key_for_search.type)
> -		return 0;
> -	if (ref1->key_for_search.objectid != ref2->key_for_search.objectid)
> -		return 0;
> -	if (ref1->key_for_search.offset != ref2->key_for_search.offset)
> -		return 0;
> -	if (ref1->parent != ref2->parent)
> +	if ((ref1->level != ref2->level) ||
> +	    (ref1->root_id != ref2->root_id) ||
> +	    (ref1->key_for_search.type != ref2->key_for_search.type) ||
> +	    (ref1->key_for_search.objectid != ref2->key_for_search.objectid) ||
> +	    (ref1->key_for_search.offset != ref2->key_for_search.offset) ||
> +	    (ref1->parent != ref2->parent))
>  		return 0;
>  
>  	return 1;
> -- 
> 1.7.9.5
>
> -- 
> You received this message because you are subscribed to the Google Groups "opw-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to opw-kernel+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Zach Brown Oct. 22, 2013, 9:30 p.m. UTC | #3
On Tue, Oct 22, 2013 at 10:01:05AM +1030, Rusty Russell wrote:
> Rashika Kheria <rashika.kheria@gmail.com> writes:
> > This patch uses '||' operator to club together the if conditions that
> > have the same body.
> >
> > Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
> 
> Hi Rashika,
> 
>         I don't like to be a curmudgeon, but I prefer the original.  The
> compiler certainly won't care, but I think this change is gratuitous.
> 
> Zach might have a different opinion, of course (and the other patch is
> great).

I honestly don't have a strong opinion either way, though I slightly
prefer the more dense version.

When generating the list of little btrfs things to cleanup I set the bar
pretty low :).

- z
Zach Brown Oct. 29, 2013, 10:57 p.m. UTC | #4
On Tue, Oct 22, 2013 at 10:01:05AM +1030, Rusty Russell wrote:
> Rashika Kheria <rashika.kheria@gmail.com> writes:
> > This patch uses '||' operator to club together the if conditions that
> > have the same body.
> >
> > Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
> 
> Hi Rashika,
> 
>         I don't like to be a curmudgeon, but I prefer the original.  The
> compiler certainly won't care, but I think this change is gratuitous.
> 
> Zach might have a different opinion, of course (and the other patch is
> great).

Yeah, now that I see the other patches, I have to agree with Rusty.  We
have enough other patches to work with so we can just drop this one.
It's not worth the churn.

- z
diff mbox

Patch

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 0552a59..c63aa34c 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -410,17 +410,12 @@  out:
 static inline int ref_for_same_block(struct __prelim_ref *ref1,
 				     struct __prelim_ref *ref2)
 {
-	if (ref1->level != ref2->level)
-		return 0;
-	if (ref1->root_id != ref2->root_id)
-		return 0;
-	if (ref1->key_for_search.type != ref2->key_for_search.type)
-		return 0;
-	if (ref1->key_for_search.objectid != ref2->key_for_search.objectid)
-		return 0;
-	if (ref1->key_for_search.offset != ref2->key_for_search.offset)
-		return 0;
-	if (ref1->parent != ref2->parent)
+	if ((ref1->level != ref2->level) ||
+	    (ref1->root_id != ref2->root_id) ||
+	    (ref1->key_for_search.type != ref2->key_for_search.type) ||
+	    (ref1->key_for_search.objectid != ref2->key_for_search.objectid) ||
+	    (ref1->key_for_search.offset != ref2->key_for_search.offset) ||
+	    (ref1->parent != ref2->parent))
 		return 0;
 
 	return 1;