Merged
Conversation
Reduced length of the encoded trie by 21% for HTML (from 15,242 words (uint16) to 12075), by: - Adding a semicolon flag on value nodes, which means semicolons don't have to be encoded anymore. - Compacting dict keys: two keys are now stored in each word, instead of one - Compacting runs of 3 or more characters: successive characters are now also stored as two characters per word Also reduces the size of the encoded table by 32% (after the previous change) by encoding it as base64.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR significantly improves the encoding efficiency of the HTML entity decode trie by implementing three main optimization strategies, resulting in a 21% reduction in trie size (from 15,242 to 12,075 words) and a 32% reduction in the encoded table size through base64 encoding.
- Added semicolon flag handling to eliminate explicit semicolon branches for strict entities
- Implemented compact dictionary keys storing two keys per word instead of one
- Added compact runs for sequences of 3+ consecutive single-child nodes
Reviewed Changes
Copilot reviewed 10 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/internal/bin-trie-flags.ts | Defines bit flags and masks for the new binary trie encoding format |
| src/decode.ts | Updates entity decoder with new trie format support including compact runs and semicolon flags |
| scripts/write-decode-map.ts | Switches from string-based encoding to base64-encoded Uint16Array for smaller output |
| scripts/trie/trie.ts | Adds semicolon requirement tracking and prevents empty next maps for leaf nodes |
| scripts/trie/encode-trie.ts | Implements compact run encoding and packed dictionary key storage |
| scripts/trie/encode-trie.spec.ts | Updates tests for new packed dictionary format |
| scripts/trie/decode-trie.ts | Adds decode support for compact runs and packed keys |
| scripts/trie/decode-trie.spec.ts | Updates merge logic to handle strict vs legacy entity semantics |
| scripts/trie/compact-run.spec.ts | Adds comprehensive tests for compact run encoding/decoding |
| scripts/trie/README.md | Documents the new encoding format including compact runs and semicolon handling |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
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.
Reduced length of the encoded trie by 21% for HTML (from 15,242 words (uint16) to 12075), by:
Also reduces the size of the encoded table by 32% (after the previous change) by encoding it as base64.