-
Notifications
You must be signed in to change notification settings - Fork 62
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
VSCODE-639: Replace regex fragment matching with streaming KMP #837
Conversation
Love it!! Looking forward to this work being finished and merged 🔥 |
6acc41f
to
c8f09f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! Nice writeup. Called out one behavioral change, but I don't think we need to make any changes to accommodate. This is already improving things by making the streaming not block until the whole code block is parsed.
// Finish up anything not streamed yet. | ||
if (contentSinceLastIdentifier.length > 0) { | ||
processStreamFragment(contentSinceLastIdentifier); | ||
for await (const fragment of inputIterable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One change in behavior that will happen is when a fragment is very large, and could contain two code blocks. It would now print all of the fragment before it adds the actions.
This won't impact our use of this since the fragments are pretty much always 2-4 characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting that. The fix for it was simple enough, so I added it anyway just to be on the safe side.
* main: VSCODE-640: Adapt message content access to latest vscode API (#857) Update changelog (#856)
Description
I got nerd-sniped by #835, and wanted to try out a regex-less implementation of the identifier matching algorithm. I've implemented a stateful streaming Knuth-Morris-Pratt algorithm for the identifier matching and then a stateful matcher for the content. Those could have been trivially combined, but I opted to keep them separate to 1) keep the concerns more cleanly separate and 2) to have the building blocks available in case we need to do a simple substring search in the stream without extracting some content between the identifiers.
While I think this approach is slightly more readable and should (theoretically) be more performant, I don't believe we should try and get it in before the code freeze as it's not fixing an actual bug.
Checklist
Motivation and Context
Open Questions
Dependents
Types of changes