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

2 messages from 2018-10-03 to 2018-10-03. Participants: René Scharfe, Johannes Schindelin.
Thread: https://gitlist.dev/t/49477

## René Scharfe, 2018-10-03 13:06

Subject: [PATCH] sequencer: use return value of oidset_insert()
Message-ID: <18bf2384-694c-f98b-1c31-3c80c07bde2a@web.de>
URL: https://gitlist.dev/e/18bf2384-694c-f98b-1c31-3c80c07bde2a%40web.de

```
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

```

## Johannes Schindelin, 2018-10-03 20:14

Subject: Re: [PATCH] sequencer: use return value of oidset_insert()
Message-ID: <nycvar.QRO.7.76.6.1810032213330.73@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.1810032213330.73%40tvgsbejvaqbjf.bet
In-Reply-To: <18bf2384-694c-f98b-1c31-3c80c07bde2a@web.de>

```
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
> 
```
