[Performance] Animation property dispatch resolves property name by strcmp cascade every frame #342
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#342
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Every active animation applies its value every frame via
Animation::applyValue→target->setProperty(targetProperty, val)(src/Animation.cpp:438, called fromAnimation::updateatsrc/Animation.cpp:264).UIFrame::setProperty(const std::string& name, float value)(src/UIFrame.cpp:843) — and the parallel implementations on the other drawables/entities — resolve the property name with a linearif (name == "x") … else if (name == "y") …string-comparison cascade. Deep properties (e.g.fill_color.a) sit at the end of the chain, ~15 comparisons deep, and this runs per animation, per frame.Cost scales with (animations × framerate): a scene animating 50 entities pays this ~3000×/sec.
Proposed fix
Resolve the property name once at
Animation::start()/startEntity()— to a property enum or a cached setter (function pointer / small dispatch handle) — and reuse it each frame instead of re-parsing the string. This mirrors the approach in #331 (stop repeating per-call ceremony in the hot path).Benchmark
Benchmarkable A/B exactly like #331: animate N properties across N frames headless, measure ns/frame before and after. Add to
tests/benchmarks/.Related: #331 (hot property getter fast-path).