Merged
Conversation
This allows whitespace to be inspected in some special cases.
Define the combination of head/kind/flags functions as a more formal API - many syntax nodes and token types need these. On top of this we can define various predicates such as `is_trivia` in one place rather than having multiple definitions of these functions.
The token_type() function no longer exists
* Use Ref to avoid triggering boxing of captures via closure variable assignment. * Use let blocks for temporary ParseState transitions to avoid some closures.
This change implements a fast-path for token lookahead in peek() and increases the size of the lookahead buffer to make this more efficient.
Manually track an index into the lookahead buffer to avoid buffer resizing. (Julia's builtin array actually uses the same strategy to avoid shuffling elements in popfront!(). But an extra layer here can help as we know more about the data access.)
Some inbounds annotations in the `peek()` hot code paths seem to provide a few percent improvement (maybe 5%)?
Member
Author
|
Overall this seems to boost the parser's speed by around 40% :-) |
c42f
added a commit
to JuliaLang/julia
that referenced
this pull request
Oct 17, 2025
…-token-lookahead Optimization and cleanup in parse stream
topolarity
pushed a commit
to JuliaLang/julia
that referenced
this pull request
Nov 14, 2025
…-token-lookahead Optimization and cleanup in parse stream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a series of cleanup/optimization commits which
ParseStreamEMPTY_TOKENin Tokenize