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

Use Tries to match with the GLSL keywords #634

Merged

Conversation

tonihele
Copy link
Contributor

@tonihele tonihele commented Dec 14, 2024

Significantly speeds up the keyword token matching by using simple Trie structure. Also the previous implementation unnecessarily looped through the keywords even if a match was already found and even tried to match them discarding the result (boolean short-circuiting done inefficiently).

I have a beast of a computer (14th gen Intel), I did this basic logging benchmark with a 87 LoC shader:
Old:
INFO [com.jme3.gde.glsl.highlighter.lexer.GlslKeywordLibrary]: Hits 1 389, total time spent 13ms
New:
INFO [com.jme3.gde.glsl.highlighter.lexer.GlslKeywordLibrary]: Hits 1 389, total time spent 0ms

(hits == how many times we enter the method, total time spent is cumulative time spent in the method)

So the speedup is a magnitude of infinite? Well, it is fast now.

@tonihele tonihele merged commit 290ba52 into jMonkeyEngine:master Dec 15, 2024
3 checks passed
@tonihele tonihele deleted the feature/optimize-glsl-highlighter branch December 15, 2024 10:57
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.

1 participant