Files
Behdad EsfahbodandClaude Opus 5.5 8ad15cfc69 [subset] Binary-search avar2 offset compensation instead of budgeting it
Offset compensation looked every breakpoint and estimator sample up in
the old segment map, the instantiated mapping and the knots by linear
search, and inserted each breakpoint knot by shifting, so its cost was
quadratic in the axis's breakpoints.  The previous commit capped that
with HB_BUDGET_SUBSET_TABLE; remove the quadratic work instead:

- SegmentMaps::map_float() takes a sorted flag; for maps whose
  fromCoords ascend it finds the exact-match run and the segment by
  binary search, which lands where the linear scans do.
- The instantiated mapping is sorted by fromCoord, and the knots by z,
  so _avar2_map_new_mapping() and _avar2_eval_offset() binary-search.
- The estimator pulls the ascending knots back through the mapping
  with one forward scan over its toCoords.
- Breakpoint knots are pushed and then sorted, keeping the first of
  equal z as _avar2_add_knot() did.

An old segment map with fromCoords out of order, which the spec
forbids, would still need a linear scan per lookup; for such an axis
keep the {-1, 0, +1, z_old} anchors and skip the estimate.

Remove HB_BUDGET_SUBSET_TABLE, now unused.

test_avar2_restrict_many_breakpoints now expects the 32,769-breakpoint
axis to instance, and to match, rather than fail; the whole test runs
in 0.2 s.  65,000-breakpoint maps instance in under 0.25 s.

Outputs are byte-identical to before for every test-subset-avar2
instance and for 317 random avar2 maps (sorted, with duplicate
fromCoords, and with non-monotone toCoords) on random ranges; only
maps with unsorted fromCoords differ.

Tested: meson test -C build (277/277 OK).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 16:41:59 -06:00
..
2025-04-06 18:08:50 -06:00
2026-07-30 19:02:25 -06:00
2026-07-31 04:31:26 +03:00
2025-04-05 22:37:10 -06:00
2020-01-15 13:36:01 -08:00
2025-06-08 13:43:27 +03:00