What is the best way to copy a Matcher? #349
Unanswered
sanbox-irl
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
I am using ohm to create a Language Server, which works in VSCode to provide diagnostics for a game's scripting language.
It's been going very well, but in recent tests, some files which hit a large length (around 800 lines) start to really get the Matcher to stutter (initial match + semantics can take upwards of 1.5 seconds).
I believe the reason is because I do a few unusual things:
Given this pseudo-example:
It will walk back from invalid to "valid0", replacing its input by slicing away with
matcher.replaceInputRange
(by replacing inputs with "") and then it will walk forward by trying to find the next "safe" place and then replacing its input withmatcher.setInput
.So it is my understanding that
replaceInputRange
is better in this scenario thansetInput
sincesinceInput
makes us lose the memoTable.matcher.replaceInputRange
I have to do amatcher.setInput
, which seems very inefficient.My idea was to "copy" the initial Matcher's input and memoTable, save it, and then put it back in after doing all my diagnostic work, so that when I have my next lint, I can just do a
replaceInputRange
which I think will give me a very nice speedboost. When I get that system working, the 1.5 second lint goes all the way down to about 400 ms., which is still awfully long, but it's a great start.Copying the memotable and input, though, produces many problems (missing functions and what not).
Please, let me know what you think of this idea. In the meantime, I'll stick with the old, less efficient system.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions