From a8fd8ddeef1a50dc5107af3e3745c4c40ee4aa67 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 24 Oct 2026 02:06:54 +0700 Subject: [PATCH] Legacy .ai pattern flattening: skip the ancestry walk for leaves without a pattern fill --- crates/engine/src/cmd/expand.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/engine/src/cmd/expand.rs b/crates/engine/src/cmd/expand.rs index 81ea48866..efcccd241 100644 --- a/crates/engine/src/cmd/expand.rs +++ b/crates/engine/src/cmd/expand.rs @@ -421,6 +421,10 @@ fn expand_pattern_fills(s: &mut Session) -> Result<()> { /// mode. Returns how many shapes changed. pub(crate) fn expand_transparent_image_patterns(d: &mut Document, root: NodeId, see_through: &BTreeSet) -> Result { let (_, n) = replace_leaves(d, root, |d, l| { + // Most leaves have no pattern fill: skip the ancestry walk for them. + if !l.appearance.items.iter().any(|i| pattern_fill(d, i).is_some()) { + return None; + } let shape = d.ancestry(l.id).unwrap_or_default().iter().filter_map(|a| d.node(*a)).any(blended); let transparent = |d: &Document, i: &AppearanceItem| { pattern_fill(d, i).is_some_and(|(f, def, _)| {