Repository navigation
Animations: index morph matching and timeline lookups by shape - #1700
Conversation
Morph pairing searched every shape of the next slide for each shape of the current one, four times over, rebuilding shape text inside each comparison. Timeline state looked up a shape's effects, paragraph owner and base colour by scanning every effect, group and colour on the slide, once per shape and paragraph drawn. Both are now indexed once, keeping the same match order.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
… tests On a loaded runner a ten-second bound can fail after every functional assertion passed. The inputs stay large enough that a quadratic regression hangs the test instead.
What was wrong
Two slideshow paths did work proportional to the product of document-controlled counts, on the rendering thread:
morph_pairssearched every shape of the next slide for each unmatched shape of the current slide, in four passes, and rebuilt each shape's text inside every comparison.morph_framethen looked up each pair with linear searches over the pair list and the slide's shapes.Timeline::state_orderedscanned the whole effect list for every shape and paragraph it evaluated, searched the full paragraph-group list for the paragraph's owner, and scanned the colour list for the base colour.paragraph_targetsandanimated_shapesdid similar full scans (with aVec::containsinside the loop).A slide with tens of thousands of shapes, or one by-paragraph build over tens of thousands of paragraphs, turned this into billions of comparisons and froze the show.
What changed
morph_pairscomputes each shape's text once and, per pass, indexes the unused shapes of the next slide by the pass's key (name, kind and text, or kind and preset geometry). The front of each key's queue is the first unused match in slide order, so pairing is exactly what the old search produced.morph_framebuilds id lookups for paired shapes once.Timelinebuilds an index (effects by target shape and paragraph, effects by shape, paragraph owners, groups by shape, base colours) when it is constructed. The fields it indexes are only written during construction. "First wins" semantics of the oldfindcalls are kept.Blast radius
deckcraft-animonly: morph transitions and animation timeline evaluation. Matching order and results are unchanged; new tests cover slide-order matching and 20,000-shape / 20,000-paragraph cases.Checks run
cargo test -p deckcraft-anim(98 passed, including the new tests)cargo clippy -p deckcraft-anim --all-targets -- -D warningscargo fmt -p deckcraft-anim --checkChecks not run
cargo xtask ciand the visual slideshow checks (deckcraft --sample); not run in this environment.Addresses CodeRabbit security findings (CWE-407).
Summary by CodeRabbit