From 99e74fa0f5cd4c5b18fde5e2c97d04afa522b350 Mon Sep 17 00:00:00 2001 From: Hendrik van Antwerpen Date: Tue, 11 Jan 2022 18:16:52 +0100 Subject: [PATCH] Move quantifier addition out of loop and drop conditional --- lib/src/query.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/src/query.c b/lib/src/query.c index b43a92c0..f0f02822 100644 --- a/lib/src/query.c +++ b/lib/src/query.c @@ -2404,14 +2404,13 @@ static TSQueryError ts_query__parse_pattern( length ); + // Add the capture quantifier + capture_quantifiers_add_for_id(capture_quantifiers, capture_id, TSQuantifierOne); + uint32_t step_index = starting_step_index; for (;;) { QueryStep *step = &self->steps.contents[step_index]; query_step__add_capture(step, capture_id); - // Add only once, not for every branch, lest the quantifier will be '+' instead of '1' - if (step_index == starting_step_index) { - capture_quantifiers_add_for_id(capture_quantifiers, capture_id, TSQuantifierOne); - } if ( step->alternative_index != NONE && step->alternative_index > step_index &&