threads / patch / 49477

patchsequencer: use return value of oidset_insert()

Subject: [PATCH] sequencer: use return value of oidset_insert()

## tl;dr

2 messages between Oct 3, 2018 and Oct 3, 2018. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

René Scharfe· Oct 3, 2018, 13:06 UTC · lore

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(-)
Show changes to sequencer.c +1 −3
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
Johannes Schindelin· Oct 3, 2018, 20:14 UTC · re: René Scharfe · lore

Re: [PATCH] sequencer: use return value of oidset_insert()

Hi René,
On Wed, 3 Oct 2018, René Scharfe wrote:
Show 6 quoted lines
> 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

Show 21 quoted lines
>  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
> 

← back to recent threads