From a0f130e23c9513b07cb8bba94beef9f14ada504e Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Sun, 17 Mar 2024 13:50:49 +0000 Subject: [PATCH] Optimize `AnimationTree::_process_graph()` Removes redundant lookups on HashMap. --- scene/animation/animation_tree.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index f7fac557212..4e3e195469e 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -827,17 +827,19 @@ void AnimationTree::_process_graph(float p_delta) { for (int i = 0; i < a->get_track_count(); i++) { NodePath path = a->track_get_path(i); - ERR_CONTINUE(!track_cache.has(path)); + TrackCache **track_pp = track_cache.getptr(path); + ERR_CONTINUE(!track_pp); - TrackCache *track = track_cache[path]; + TrackCache *track = *track_pp; if (track->type != a->track_get_type(i)) { continue; //may happen should not } track->root_motion = root_motion_track == path; - ERR_CONTINUE(!state.track_map.has(path)); - int blend_idx = state.track_map[path]; + int *blend_idx_p = state.track_map.getptr(path); + ERR_CONTINUE(!blend_idx_p); + int blend_idx = *blend_idx_p; ERR_CONTINUE(blend_idx < 0 || blend_idx >= state.track_count);