Repository navigation
Conversation
Matcher and first-value closures multiply the large contextual rule loops for glyph matching and each class-cache mode. Replace them with borrowed glyph/class matchers while retaining typed rule parsing and the existing cache sentinels, probes, and malformed-rule handling. This reduces chained-rule matcher instances from eight to three and saves about 52 KiB of text in release/LTO shaping binaries. The measured tradeoff is about 6% slower Nastaliq shaping; other samples remain close to the baseline. Add direct tests for wide glyph/class values and class-cache sentinels and nibble preservation. Workspace all-feature tests (including 6073 shaping cases), strict Clippy, formatting, and Rust 1.85 no-std ARM build pass. Assisted-by: OpenAI Codex
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.
Stacked on #495; this PR contains only the contextual-matcher sharing change.
Replace matcher/first-value closure types with concrete borrowed glyph/class
matchers. This keeps the existing parsing, rule probes, malformed-rule fallback,
and cache behavior, but stops duplicating the large matching loops for every
closure/cache mode. No allocations or trait-object dispatch are added.
In the measured release/LTO build, the large chained-rule matcher goes from
eight instances to three, saving about 52 KiB of ELF text in both
hr-shapeand the C API library.
Performance tradeoff
The Nastaliq sample is about 6–8% slower. This is an intentional size/speed
tradeoff, not a performance-neutral refactor. The first measurement was +6.1%;
after rebasing onto the cursive-sharing change (#498), a fresh comparison measured
+8.4%. A partially specialized prototype removed the initial regression but saved
only about 24 KiB; we chose the larger saving.
CPU-pinned, alternating before/after runs on Linux x86-64, Rust 1.89, release
optimization with fat LTO and one codegen unit. The latest comparison against the
base including #498 uses eight samples per binary:
These are individual text samples, not a claim about all fonts or workloads.
Glyphs, positions, and flags match the baseline in all four directions for the
six samples.
Validation
preservation of the other cached nibble.
thumbv7em-none-eabihfwithlibm.