From 4423a8046098c8667b9edea22d1db6452a809ae5 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 15 Oct 2026 11:59:38 -0600 Subject: [PATCH] [subset] Share mark-class remapping across record widths Mark classes remain 16-bit values in both mark-record representations; only the record stride and array count differ. Decode those in the wrapper and share the class collection and remapping work. Give the common helper hidden inline linkage so its body is shared across translation units as well as record formats. Class ordering, existing mappings, and allocation behavior are preserved. With GCC 15.3 on x86-64 without LTO, this removes 1152 bytes of subset code/read-only data at -O3 and 1440 bytes at -Os. Validated with the full Meson suite (292 passed, one skipped) and subset benchmarks. Assisted-by: OpenAI Codex --- src/OT/Layout/GPOS/MarkArray.hh | 38 ++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/OT/Layout/GPOS/MarkArray.hh b/src/OT/Layout/GPOS/MarkArray.hh index af840c806..fecb47f5a 100644 --- a/src/OT/Layout/GPOS/MarkArray.hh +++ b/src/OT/Layout/GPOS/MarkArray.hh @@ -147,21 +147,22 @@ struct MarkArray : Types::template ArrayOf> } }; -template HB_INTERNAL inline -void Markclass_closure_and_remap_indexes (const Coverage &mark_coverage, - const MarkArray &mark_array, - const hb_set_t &glyphset, - hb_map_t* klass_mapping /* INOUT */) +void Markclass_closure_and_remap_indexes (const Coverage &mark_coverage, + const void *mark_records, + unsigned count, + unsigned record_size, + const hb_set_t &glyphset, + hb_map_t *klass_mapping) { hb_set_t orig_classes; - - + hb_zip (mark_coverage, mark_array) - | hb_filter (glyphset, hb_first) - | hb_map (hb_second) - | hb_map (&MarkRecord::get_class) - | hb_sink (orig_classes) - ; + for (const auto _ : hb_zip (mark_coverage, hb_range (count))) + if (glyphset.has (_.first)) + { + const auto *klass = reinterpret_cast + ((const char *) mark_records + _.second * record_size); + orig_classes.add (*klass); + } unsigned idx = 0; for (auto klass : orig_classes.iter ()) @@ -172,6 +173,19 @@ void Markclass_closure_and_remap_indexes (const Coverage &mark_coverage, } } +template +HB_INTERNAL inline +void Markclass_closure_and_remap_indexes (const Coverage &mark_coverage, + const MarkArray &mark_array, + const hb_set_t &glyphset, + hb_map_t* klass_mapping /* INOUT */) +{ + Markclass_closure_and_remap_indexes (mark_coverage, + mark_array.arrayZ, mark_array.len, + MarkRecord::static_size, + glyphset, klass_mapping); +} + } } }