hoon: lightly improve parser performance #7273
Open
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.
d5af20f rewrites
+inde(indentation block parser, used for multi-line strings). Previously, +inde would reparse all contiguous parts of the input that had the same (or deeper) indentation level, even after the block's closing.Here, we make it take the opening and closing parse rules as explicit arguments, automatically include the leading and trailing newlines in the implementation, and reparse only up to the block's closing.
Parsing
hoon.hoonbecomes negligibly faster.Parsing a degenerate version of
hoon.hoon, where the first arm is a'''block-cord without any indentation, becomes ~25% faster.Parsing
/lib/language-server/rune-snippet, which contains many"""block-tapes at the same indentation level, becomes ~45% faster.This also turns
+iny, whose implementation was a one-to-one copy of+inde, into an alias for+inde.d9c3d7b wraps the parsers in
+rope'spose(the wing parsers) inside a+stewinstead. Nearly all of its different cases are distinguishable by its first character, making it a good candidate for this.This improves the performance of parsing
hoon.hoonby ~10%.No tests specifically for the multi-line string parsing, but did catch (and patch) some accidental breakage when building tests and other files. I expect it to have parity.