Skip to content

Commit 99e74fa

Browse files
author
Hendrik van Antwerpen
committed
Move quantifier addition out of loop and drop conditional
1 parent 93db863 commit 99e74fa

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/src/query.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,14 +2404,13 @@ static TSQueryError ts_query__parse_pattern(
24042404
length
24052405
);
24062406

2407+
// Add the capture quantifier
2408+
capture_quantifiers_add_for_id(capture_quantifiers, capture_id, TSQuantifierOne);
2409+
24072410
uint32_t step_index = starting_step_index;
24082411
for (;;) {
24092412
QueryStep *step = &self->steps.contents[step_index];
24102413
query_step__add_capture(step, capture_id);
2411-
// Add only once, not for every branch, lest the quantifier will be '+' instead of '1'
2412-
if (step_index == starting_step_index) {
2413-
capture_quantifiers_add_for_id(capture_quantifiers, capture_id, TSQuantifierOne);
2414-
}
24152414
if (
24162415
step->alternative_index != NONE &&
24172416
step->alternative_index > step_index &&

0 commit comments

Comments
 (0)