Skip to content

Commit e6aa06d

Browse files
committed
Merge pull request godotengine#112692 from TokageItLab/rbmap-animlib
Make AnimationLibrary use RBMap instead of HashMap
2 parents 08fb2e6 + e9a6a84 commit e6aa06d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

scene/resources/animation_library.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ Error AnimationLibrary::add_animation(const StringName &p_name, const Ref<Animat
4949
ERR_FAIL_COND_V(p_animation.is_null(), ERR_INVALID_PARAMETER);
5050

5151
if (animations.has(p_name)) {
52-
animations.get(p_name)->disconnect_changed(callable_mp(this, &AnimationLibrary::_animation_changed));
52+
animations[p_name]->disconnect_changed(callable_mp(this, &AnimationLibrary::_animation_changed));
5353
animations.erase(p_name);
5454
emit_signal(SNAME("animation_removed"), p_name);
5555
}
5656

5757
animations.insert(p_name, p_animation);
58-
animations.get(p_name)->connect_changed(callable_mp(this, &AnimationLibrary::_animation_changed).bind(p_name));
58+
animations[p_name]->connect_changed(callable_mp(this, &AnimationLibrary::_animation_changed).bind(p_name));
5959
emit_signal(SNAME("animation_added"), p_name);
6060
notify_property_list_changed();
6161
return OK;
@@ -64,7 +64,7 @@ Error AnimationLibrary::add_animation(const StringName &p_name, const Ref<Animat
6464
void AnimationLibrary::remove_animation(const StringName &p_name) {
6565
ERR_FAIL_COND_MSG(!animations.has(p_name), vformat("Animation not found: %s.", p_name));
6666

67-
animations.get(p_name)->disconnect_changed(callable_mp(this, &AnimationLibrary::_animation_changed));
67+
animations[p_name]->disconnect_changed(callable_mp(this, &AnimationLibrary::_animation_changed));
6868
animations.erase(p_name);
6969
emit_signal(SNAME("animation_removed"), p_name);
7070
notify_property_list_changed();
@@ -75,8 +75,8 @@ void AnimationLibrary::rename_animation(const StringName &p_name, const StringNa
7575
ERR_FAIL_COND_MSG(!is_valid_animation_name(p_new_name), "Invalid animation name: '" + String(p_new_name) + "'.");
7676
ERR_FAIL_COND_MSG(animations.has(p_new_name), vformat("Animation name \"%s\" already exists in library.", p_new_name));
7777

78-
animations.get(p_name)->disconnect_changed(callable_mp(this, &AnimationLibrary::_animation_changed));
79-
animations.get(p_name)->connect_changed(callable_mp(this, &AnimationLibrary::_animation_changed).bind(p_new_name));
78+
animations[p_name]->disconnect_changed(callable_mp(this, &AnimationLibrary::_animation_changed));
79+
animations[p_name]->connect_changed(callable_mp(this, &AnimationLibrary::_animation_changed).bind(p_new_name));
8080
animations.insert(p_new_name, animations[p_name]);
8181
animations.erase(p_name);
8282
emit_signal(SNAME("animation_renamed"), p_name, p_new_name);

scene/resources/animation_library.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#pragma once
3232

33+
#include "core/templates/rb_map.h"
3334
#include "core/variant/typed_array.h"
3435
#include "scene/resources/animation.h"
3536

@@ -44,7 +45,7 @@ class AnimationLibrary : public Resource {
4445
void _animation_changed(const StringName &p_name);
4546

4647
friend class AnimationMixer; // For faster access.
47-
HashMap<StringName, Ref<Animation>> animations;
48+
RBMap<StringName, Ref<Animation>, StringName::AlphCompare> animations;
4849

4950
protected:
5051
static void _bind_methods();

0 commit comments

Comments
 (0)