Skip to content

fix(Trie): avoid scanning siblings on path updates - #144

Merged
favonia merged 1 commit into
mainfrom
fix/trie-tag-cardinality
Dec 1, 2026
Merged

favonia merged 1 commit into
mainfrom
fix/trie-tag-cardinality

Conversation

@favonia

@favonia favonia commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Inserting sibling names one at a time took quadratic time because the trie repeatedly counted all children to check whether any still inherited the default tag. I'd assumed Map.cardinal was O(1), but it traverses the whole map.

The trie now maintains two counts: the total number of children and the number with explicit tags. When the counts match, every child has an explicit tag and the default can be dropped. The check takes O(1) time.

Thanks to @mikeshulman for reporting this issue.

@favonia
favonia force-pushed the fix/trie-tag-cardinality branch from b0565fc to 628f2fe Compare November 30, 2026 18:03
@favonia
favonia merged commit 2df69f5 into main Dec 1, 2026
1 check passed
@favonia
favonia deleted the fix/trie-tag-cardinality branch December 1, 2026 15:36
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