All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: rtl8188eu: Refactor loop to increase compactness
@ 2015-02-27 18:07 Vatika Harlalka
  2015-02-27 18:14 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Vatika Harlalka @ 2015-02-27 18:07 UTC (permalink / raw)
  To: outreachy-kernel

The variables tmp1 and tmp2 are assigned the same values
in the nested else and the outer else. They can be 
assigned without nesting to increase readability.

Signed-off-by: Vatika Harlalka <vatikaharlalka@gmail.com>
---
 drivers/staging/rtl8188eu/hal/phy.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c
index 3d0e447..05379be 100644
--- a/drivers/staging/rtl8188eu/hal/phy.c
+++ b/drivers/staging/rtl8188eu/hal/phy.c
@@ -1039,18 +1039,12 @@ static bool simularity_compare(struct adapter *adapt, s32 resulta[][8],
 
 	for (i = 0; i < bound; i++) {
 		if (i%2 == 1) {
+			tmp1 = resulta[c1][i];
+			tmp2 = resulta[c2][i];
 			if ((resulta[c1][i] & 0x00000200) != 0)
 				tmp1 = resulta[c1][i] | 0xFFFFFC00;
-			else
-				tmp1 = resulta[c1][i];
-
 			if ((resulta[c2][i] & 0x00000200) != 0)
 				tmp2 = resulta[c2][i] | 0xFFFFFC00;
-			else
-				tmp2 = resulta[c2][i];
-		} else {
-			tmp1 = resulta[c1][i];
-			tmp2 = resulta[c2][i];
 		}
 
 		diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1);
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Refactor loop to increase compactness
  2015-02-27 18:07 [PATCH] Staging: rtl8188eu: Refactor loop to increase compactness Vatika Harlalka
@ 2015-02-27 18:14 ` Julia Lawall
  2015-02-27 18:23   ` Vatika Harlalka
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2015-02-27 18:14 UTC (permalink / raw)
  To: Vatika Harlalka; +Cc: outreachy-kernel

On Fri, 27 Feb 2015, Vatika Harlalka wrote:

> The variables tmp1 and tmp2 are assigned the same values
> in the nested else and the outer else. They can be
> assigned without nesting to increase readability.
>
> Signed-off-by: Vatika Harlalka <vatikaharlalka@gmail.com>
> ---
>  drivers/staging/rtl8188eu/hal/phy.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c
> index 3d0e447..05379be 100644
> --- a/drivers/staging/rtl8188eu/hal/phy.c
> +++ b/drivers/staging/rtl8188eu/hal/phy.c
> @@ -1039,18 +1039,12 @@ static bool simularity_compare(struct adapter *adapt, s32 resulta[][8],
>
>  	for (i = 0; i < bound; i++) {
>  		if (i%2 == 1) {
> +			tmp1 = resulta[c1][i];
> +			tmp2 = resulta[c2][i];

I find this confusing.  There is an assignment that is just there to be
written over in one case.

julia

>  			if ((resulta[c1][i] & 0x00000200) != 0)
>  				tmp1 = resulta[c1][i] | 0xFFFFFC00;
> -			else
> -				tmp1 = resulta[c1][i];
> -
>  			if ((resulta[c2][i] & 0x00000200) != 0)
>  				tmp2 = resulta[c2][i] | 0xFFFFFC00;
> -			else
> -				tmp2 = resulta[c2][i];
> -		} else {
> -			tmp1 = resulta[c1][i];
> -			tmp2 = resulta[c2][i];
>  		}
>
>  		diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1);
> --
> 1.9.1
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20150227180728.GA22813%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Refactor loop to increase compactness
  2015-02-27 18:14 ` [Outreachy kernel] " Julia Lawall
@ 2015-02-27 18:23   ` Vatika Harlalka
  2015-02-27 18:27     ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Vatika Harlalka @ 2015-02-27 18:23 UTC (permalink / raw)
  To: Julia Lawall; +Cc: outreachy-kernel

[-- Attachment #1: Type: text/plain, Size: 202 bytes --]

My understanding was that since the inner nested else
and the outer else were doing the same thing, we could
make it more compact by assigning it before-hand and only
updating the values when required.

[-- Attachment #2: Type: text/html, Size: 270 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] Staging: rtl8188eu: Refactor loop to increase compactness
  2015-02-27 18:23   ` Vatika Harlalka
@ 2015-02-27 18:27     ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2015-02-27 18:27 UTC (permalink / raw)
  To: Vatika Harlalka; +Cc: outreachy-kernel

On Fri, 27 Feb 2015, Vatika Harlalka wrote:

> My understanding was that since the inner nested else
> and the outer else were doing the same thing, we could
> make it more compact by assigning it before-hand and only
> updating the values when required.

I agree that the transformation is correct.  But I think that the result
could be confusing.

Good effort to think about these things though :)

julia


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-02-27 18:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-27 18:07 [PATCH] Staging: rtl8188eu: Refactor loop to increase compactness Vatika Harlalka
2015-02-27 18:14 ` [Outreachy kernel] " Julia Lawall
2015-02-27 18:23   ` Vatika Harlalka
2015-02-27 18:27     ` Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.