git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] use || instead of | in logical expressions
@ 2009-01-01 22:39 Alexander Potashev
  2009-01-01 23:07 ` Alexander Potashev
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Potashev @ 2009-01-01 22:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

Bit OR ('|') is probably faster and it always works correctly (but '&'
doesn't!), but it looks horrible here.

Signed-off-by: Alexander Potashev <aspotashev@gmail.com>
---
 builtin-apply.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/builtin-apply.c b/builtin-apply.c
index 07244b0..c71afa1 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2487,7 +2487,7 @@ static int check_patch(struct patch *patch)
 		ok_if_exists = 0;
 
 	if (new_name &&
-	    ((0 < patch->is_new) | (0 < patch->is_rename) | patch->is_copy)) {
+	    (0 < patch->is_new || 0 < patch->is_rename || patch->is_copy)) {
 		if (check_index &&
 		    cache_name_pos(new_name, strlen(new_name)) >= 0 &&
 		    !ok_if_exists)
-- 
1.6.0.6

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

* Re: [PATCH] use || instead of | in logical expressions
  2009-01-01 22:39 [PATCH] use || instead of | in logical expressions Alexander Potashev
@ 2009-01-01 23:07 ` Alexander Potashev
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Potashev @ 2009-01-01 23:07 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

On 01:39 Fri 02 Jan     , Alexander Potashev wrote:
> Bit OR ('|') is probably faster and it always works correctly (but '&'
> doesn't!), but it looks horrible here.

Sorry, I was wrong: '&' would work as well (for example in expression
'(a < 1) & (b == 5)') because logical operators can return only 0 or 1.

> 
> Signed-off-by: Alexander Potashev <aspotashev@gmail.com>
> ---
>  builtin-apply.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/builtin-apply.c b/builtin-apply.c
> index 07244b0..c71afa1 100644
> --- a/builtin-apply.c
> +++ b/builtin-apply.c
> @@ -2487,7 +2487,7 @@ static int check_patch(struct patch *patch)
>  		ok_if_exists = 0;
>  
>  	if (new_name &&
> -	    ((0 < patch->is_new) | (0 < patch->is_rename) | patch->is_copy)) {
> +	    (0 < patch->is_new || 0 < patch->is_rename || patch->is_copy)) {
>  		if (check_index &&
>  		    cache_name_pos(new_name, strlen(new_name)) >= 0 &&
>  		    !ok_if_exists)
> -- 
> 1.6.0.6
> 

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

end of thread, other threads:[~2009-01-01 23:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-01 22:39 [PATCH] use || instead of | in logical expressions Alexander Potashev
2009-01-01 23:07 ` Alexander Potashev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).