Skip to content

[gpos] Share cursive attachment across glyph-ID widths - #498

Merged
behdad merged 1 commit into
feat/extended-layoutfrom
perf/share-cursive-attachment
Oct 5, 2026
Merged

behdad merged 1 commit into
feat/extended-layoutfrom
perf/share-cursive-attachment

Conversation

@behdad

@behdad behdad commented Oct 5, 2026

Copy link
Copy Markdown
Member

Stacked on #495; this diff is only the cursive sharing change.

Keep CursivePos1/2 coverage and offset parsing format-specific, but share anchor resolution and attachment adjustment in one non-generic helper. No heap allocation or trait-object dispatch is introduced. Reuse child/parent position references to avoid repeated indexing, and test both formats against the same four-direction and right-to-left lookup-flag expectations.

Measured against a851c09 with identical dependencies and Rust 1.89 x86-64 release/fat-LTO settings:

  • hr-shape: ELF text + data decreases by 920 bytes.
  • libharfrust_c.so: ELF text + data decreases by 928 bytes.
  • Native Cargo stripped file sizes stay unchanged due to ELF alignment.

Eight alternating CPU-pinned samples per case, reusing the font/plan/buffer across inner iterations: Amiri −0.55%, Nastaliq −0.24%, Naskh +0.70%, Latin −0.35% median elapsed time. These small differences do not establish a speed improvement or regression. Before/after shaping output, positions and flags match in all four directions.

Validation: full all-feature workspace tests (6073 shaping regressions), strict all-target/all-feature Clippy, fmt, and no-std/libm check.

Keep the format-specific coverage and anchor-offset readers in their
wrappers, and share anchor resolution and attachment adjustment through
a non-generic, non-inlined helper. Reuse child and parent position
references instead of repeating bounds-checked indexing.

Exercise both CursivePos formats in the all-direction attachment test,
including the right-to-left lookup flag. No allocations or trait-object
dispatch are added.

On x86-64 Rust 1.89 release/fat-LTO builds, ELF text plus data shrinks by
920 bytes for hr-shape and 928 bytes for the C API. Stripped file sizes
are unchanged because of segment alignment. Alternating pinned shaping
benchmarks on Arabic, Urdu and Latin samples remain within about 1%.

Tested with the complete all-feature workspace suite (including 6073
shaping regressions), strict Clippy, formatting, and a no-std/libm check.
Shaping output and flags match the baseline in all four directions.

Assisted-by: OpenAI Codex
@behdad
behdad merged commit 32c3024 into feat/extended-layout Oct 5, 2026
4 of 6 checks passed
@behdad
behdad deleted the perf/share-cursive-attachment branch October 5, 2026 23:48
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