DRY up feature/region codegen with shared table + lookup helpers#694
Merged
Conversation
The feature and region generators each hand-rolled the same two patterns: a version-string intern table (`BTreeSet` -> sorted `Vec<String>` -> value->index map -> save blob) and a keys-blob-plus-lookup-function emission. The latter had drifted out of sync (one used `match`/`static RANGES`, the other `.ok()?`/`const RANGES`). Extract two shared helpers in `xtask` utils: - `intern_table`: dedup+sort strings into a table, save it, return the table and a value->`u16` index map. - `generate_keyed_lookup`: save a key table and emit the standard binary-search accessor module (`get_*` -> `Struct::new(RANGES[i], RANGES[i + 1])`). Both generators now call them, so the generated `get_feature_stat` / `get_usage_by_region` are identical in shape. No data change: every `.deflate` blob is byte-identical; only the generated lookup `.rs` style is unified. All tests and the JS-equivalence proptests pass.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #694 +/- ##
=======================================
Coverage 98.81% 98.81%
=======================================
Files 47 47
Lines 2443 2443
=======================================
Hits 2414 2414
Misses 29 29 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Merged
Boshen
pushed a commit
that referenced
this pull request
May 29, 2026
## 🤖 New release * `oxc-browserslist`: 3.0.3 -> 3.0.4 (✓ API compatible changes) <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## [3.0.4](oxc-browserslist-v3.0.3...oxc-browserslist-v3.0.4) - 2026-05-29 ### Other - DRY up feature/region codegen with shared table + lookup helpers ([#694](#694)) - Consolidate bundled-data loading behind compression helpers ([#693](#693)) - Reduce binary size: run-length encode feature support versions ([#692](#692)) - Reduce binary size: Zopfli codegen compression + percentage byte-plane ([#691](#691)) - Reduce binary size: byte-plane (stream-split) compression for region pair indices ([#690](#690)) - Update README binary size to 621K ([#689](#689)) - Reduce binary size of bundled caniuse/electron data ([#688](#688)) - Switch codegen data source from caniuse-db to caniuse-lite ([#687](#687)) - Update browserslist ([#685](#685)) - Update rust crates ([#682](#682)) - Update browserslist ([#679](#679)) - Update browserslist ([#678](#678)) - Update browserslist ([#677](#677)) - Update browserslist ([#673](#673)) - Update browserslist ([#671](#671)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). Co-authored-by: oxc-guard[bot] <276638029+oxc-guard[bot]@users.noreply.github.com>
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.
The feature and region data generators each hand-rolled the same two patterns, which had drifted apart over time:
BTreeSet→ sortedVec<String>→ value→index map → save blob._keys.binand emit a binary-search accessor. These had become inconsistent: the feature one usedmatch+static RANGES, the region one used.ok()?+const RANGES.This extracts two shared helpers in
xtaskutils:intern_table(blob, values)— dedup + lexicographically sort into a table, save it compressed, and return the table plus a value→u16index map.generate_keyed_lookup(...)— save a key table and emit the one standard accessor shape: binary-search the keys forname, then buildStruct::new(RANGES[i], RANGES[i + 1]).Both
build_caniuse_feature_matchingandbuild_caniuse_region_matchingnow call them, soget_feature_statandget_usage_by_regionare byte-for-byte identical in shape.No data change
Every
.deflateblob is byte-identical (regenerated to confirm); only the generated lookup.rsstyle is unified. All tests and the JS-equivalence proptests pass; clippy/fmt clean.🤖 Generated with Claude Code