Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: TokenSet instead of vararg array of token elements #296

Open
jansorg opened this issue Apr 7, 2022 · 0 comments
Open

Idea: TokenSet instead of vararg array of token elements #296

jansorg opened this issue Apr 7, 2022 · 0 comments
Labels

Comments

@jansorg
Copy link

jansorg commented Apr 7, 2022

The generated parser uses varargs to find a matching token. For heavily used rules this is allocating a lot of memory.
I'm not sure if this is feasible, but creating a static TokenSet for the tokens instead of allocating an array for each invocation could reduce allocations (and thus GC) a lot.
Thank you for your consideration!

public static boolean process_substitution(PsiBuilder b, int l) {
    if (!recursion_guard_(b, l, "process_substitution")) return false;
// here, a static TokenSet could be passed to avoid the implicit array allocation
    if (!nextTokenIsFast(b, INPUT_PROCESS_SUBSTITUTION, OUTPUT_PROCESS_SUBSTITUTION)) return false;
//...
}
@gregsh gregsh added the Feature label Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants