Repository navigation
Implement single-dict fast-path for pure-union PrefixMatch subtrees - #1367
Merged
Merged
Conversation
frankslin
force-pushed
the
upstream-master
branch
from
June 30, 2026 05:11
a10b61c to
86f8091
Compare
When a dict group's entire subtree consists only of union groups and leaf dicts (no short_circuit node anywhere), union is associative and the tree is semantically equivalent to a single flat union of all its leaves. A single LeafMatcher trie traversal finds the longest match across every leaf, which equals the multi-trie result while eliminating GroupMatcher dispatch and redundant trie walks. Adds CanFlattenAsUnion (recursive predicate) and CollectAllLeafDicts (leaf accumulator), wired into BuildMatcher as an early-exit fast-path before the existing GroupMatcher construction.
frankslin
force-pushed
the
upstream-master
branch
from
June 30, 2026 14:11
86f8091 to
9c5ea7b
Compare
Collaborator
Author
|
經測試,三種輸入長度(7.7kb 44kb 630kb)s2t 均都有穩定的 16–22% 提升,且越長的輸入優勢越明顯。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When a dict group's entire subtree consists only of union groups and
leaf dicts (no short_circuit node anywhere), union is associative and
the tree is semantically equivalent to a single flat union of all its
leaves. A single LeafMatcher trie traversal finds the longest match
across every leaf, which equals the multi-trie result while eliminating
GroupMatcher dispatch and redundant trie walks.
Adds CanFlattenAsUnion (recursive predicate) and CollectAllLeafDicts
(leaf accumulator), wired into BuildMatcher as an early-exit fast-path
before the existing GroupMatcher construction.