script: Do not iterate through all image frames when advancing animated images (#38857)

Instead of iterating through all frames every time we are looking for a
particular frame, just index into the `Vec` of frames directly. This
should do less work on every frame transition.

Testing: This is just a small optimization, so shouldn't change
observable
behavior.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-08-22 10:44:57 -07:00 committed by GitHub
parent fd3ea8854f
commit 2f44ba5168
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 7 deletions

View file

@ -72,8 +72,7 @@ impl ImageAnimationManager {
let image = &state.image;
let frame = image
.frames()
.nth(state.active_frame)
.frame(state.active_frame)
.expect("active_frame should within range of frames");
if let Some(node) = rooted_nodes.get(&NoTrace(*node)) {