diff mbox series

sequencer: use return value of oidset_insert()

Message ID 18bf2384-694c-f98b-1c31-3c80c07bde2a@web.de (mailing list archive)
State New, archived
Headers show
Series sequencer: use return value of oidset_insert() | expand

Commit Message

René Scharfe Oct. 3, 2018, 1:06 p.m. UTC
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(-)

Comments

Johannes Schindelin Oct. 3, 2018, 8:14 p.m. UTC | #1
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
>
diff mbox series

Patch

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);
 		}