git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sequencer: use return value of oidset_insert()
@ 2018-10-03 13:06 René Scharfe
  2018-10-03 20:14 ` Johannes Schindelin
  0 siblings, 1 reply; 2+ messages in thread
From: René Scharfe @ 2018-10-03 13:06 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Johannes Schindelin

oidset_insert() returns 1 if the object ID is already in the set and
doesn't add it again, or 0 if it hadn't been present.  Make use of that
fact instead of checking with an extra oidset_contains() call.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 sequencer.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index ddb41a62d9..6387c9ee6e 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -4146,9 +4146,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
 			struct object_id *oid = &parent->item->object.oid;
 			if (!oidset_contains(&interesting, oid))
 				continue;
-			if (!oidset_contains(&child_seen, oid))
-				oidset_insert(&child_seen, oid);
-			else
+			if (oidset_insert(&child_seen, oid))
 				label_oid(oid, "branch-point", &state);
 		}
 
-- 
2.19.0

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

* Re: [PATCH] sequencer: use return value of oidset_insert()
  2018-10-03 13:06 [PATCH] sequencer: use return value of oidset_insert() René Scharfe
@ 2018-10-03 20:14 ` Johannes Schindelin
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Schindelin @ 2018-10-03 20:14 UTC (permalink / raw)
  To: René Scharfe; +Cc: Git List, Junio C Hamano

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

Hi René,

On Wed, 3 Oct 2018, René Scharfe wrote:

> oidset_insert() returns 1 if the object ID is already in the set and
> doesn't add it again, or 0 if it hadn't been present.  Make use of that
> fact instead of checking with an extra oidset_contains() call.
> 
> Signed-off-by: Rene Scharfe <l.s.r@web.de>
> ---

ACK!

Thanks,
Dscho

>  sequencer.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/sequencer.c b/sequencer.c
> index ddb41a62d9..6387c9ee6e 100644
> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -4146,9 +4146,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
>  			struct object_id *oid = &parent->item->object.oid;
>  			if (!oidset_contains(&interesting, oid))
>  				continue;
> -			if (!oidset_contains(&child_seen, oid))
> -				oidset_insert(&child_seen, oid);
> -			else
> +			if (oidset_insert(&child_seen, oid))
>  				label_oid(oid, "branch-point", &state);
>  		}
>  
> -- 
> 2.19.0
> 

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

end of thread, other threads:[~2018-10-03 20:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-03 13:06 [PATCH] sequencer: use return value of oidset_insert() René Scharfe
2018-10-03 20:14 ` Johannes Schindelin

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).