Count assign colors lanes without legacy conversion and cache the offsets

This commit is contained in:
Dennis Kobert
2026-08-24 14:48:58 +00:00
parent 027218f16c
commit 9cdaf06ca9
2 changed files with 47 additions and 4 deletions

View File

@@ -770,6 +770,20 @@ const _: () = {
};
/// The graphic with every `Group` converted to its legacy form.
/// The count [`map_groups_to_legacy`] would expose through [`Graphic::as_vector`],
/// read from the run's lanes instead of materializing the legacy list. Mirrors
/// [`group_to_legacy_graphic`]'s typed-run path, where `Vector` is tried first.
pub fn direct_vector_len(graphic: &Graphic) -> usize {
match graphic {
Graphic::Vector(list) => list.len(),
Graphic::Group(group) => match (&group.row, &group.content) {
(None, core_types::record::GroupContent::Run(item)) => item.typed_lanes::<Vector>().map_or(0, |lanes| lanes.len()),
_ => 0,
},
_ => 0,
}
}
pub fn map_groups_to_legacy(graphic: &Graphic) -> Graphic {
match graphic {
Graphic::Group(group) => group_to_legacy_graphic(group),