Skip to content

cleanup: token set variant loop - #464

Merged
Max Medvedev (maxmedvedev) merged 1 commit into
JetBrains:masterfrom
goto1134:cleanup/token-set-variant-loop
Sep 19, 2026
Merged

Max Medvedev (maxmedvedev) merged 1 commit into
JetBrains:masterfrom
goto1134:cleanup/token-set-variant-loop

Conversation

@goto1134

Copy link
Copy Markdown
Contributor

No description provided.

@goto1134

Copy link
Copy Markdown
Contributor Author

Merge after #458

consumeToken(TokenSet) skipped whitespace and then called addVariant per
token, and addVariant skips whitespace again, re-reads the token index and
re-checks the completion state every time. An n-token set did n+1 whitespace
skips. nextTokenIsSlow looped over addVariant the same way.

Extract addVariants, which does the skip, the index read and the completion
check once. Nothing in the loop advances the lexer, so all three are
loop-invariant and the same variants land in the same order.

TokenSetVariantsTest covers the contract this preserves: the expected text
names every token of the set instead of rendering the IElementType[].
@goto1134
Andrei Efanov (goto1134) force-pushed the cleanup/token-set-variant-loop branch from fc5ec56 to 91a546c Compare August 29, 2026 10:23
@goto1134
Andrei Efanov (goto1134) marked this pull request as ready for review August 29, 2026 10:23
@maxmedvedev
Max Medvedev (maxmedvedev) merged commit f571e7f into JetBrains:master Sep 19, 2026
5 checks passed
@goto1134
Andrei Efanov (goto1134) deleted the cleanup/token-set-variant-loop branch September 19, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants