[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 <codex@openai.com>
This commit is contained in:
Behdad Esfahbod committed 2026-10-15 11:59:38 -06:00
1 parent 1ea14e1cf1
commit 4423a80460
1 file changed
+26 -12
+26 -12
View File
@@ -147,21 +147,22 @@ struct MarkArray : Types::template ArrayOf<MarkRecord<Types>>
}
};
template <typename Types>
HB_INTERNAL inline
void Markclass_closure_and_remap_indexes (const Coverage &mark_coverage,
const MarkArray<Types> &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<Types>::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 HBUINT16 *>
((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 <typename Types>
HB_INTERNAL inline
void Markclass_closure_and_remap_indexes (const Coverage &mark_coverage,
const MarkArray<Types> &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<Types>::static_size,
glyphset, klass_mapping);
}
}
}
}