From 6631f66c2a9d54dc80d57df60376c84ce1252d08 Mon Sep 17 00:00:00 2001 From: reduz Date: Sat, 17 Jul 2021 18:22:52 -0300 Subject: Optimize StringName usage * Added a new macro SNAME() that constructs and caches a local stringname. * Subsequent usages use the cached version. * Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time. * Replaced all theme usages by this new macro. * Replace all signal emission usages by this new macro. * Replace all call_deferred usages by this new macro. This is part of ongoing work to optimize GUI and the editor. --- scene/gui/base_button.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'scene/gui/base_button.cpp') diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 8414c4dc78..75a4464a40 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -125,7 +125,7 @@ void BaseButton::_pressed() { get_script_instance()->call(SceneStringNames::get_singleton()->_pressed); } pressed(); - emit_signal("pressed"); + emit_signal(SNAME("pressed")); } void BaseButton::_toggled(bool p_pressed) { @@ -133,14 +133,14 @@ void BaseButton::_toggled(bool p_pressed) { get_script_instance()->call(SceneStringNames::get_singleton()->_toggled, p_pressed); } toggled(p_pressed); - emit_signal("toggled", p_pressed); + emit_signal(SNAME("toggled"), p_pressed); } void BaseButton::on_action_event(Ref p_event) { if (p_event->is_pressed()) { status.press_attempt = true; status.pressing_inside = true; - emit_signal("button_down"); + emit_signal(SNAME("button_down")); } if (status.press_attempt && status.pressing_inside) { @@ -153,7 +153,7 @@ void BaseButton::on_action_event(Ref p_event) { status.pressed = !status.pressed; _unpress_group(); if (button_group.is_valid()) { - button_group->emit_signal("pressed", this); + button_group->emit_signal(SNAME("pressed"), this); } _toggled(status.pressed); _pressed(); @@ -174,7 +174,7 @@ void BaseButton::on_action_event(Ref p_event) { } status.press_attempt = false; status.pressing_inside = false; - emit_signal("button_up"); + emit_signal(SNAME("button_up")); } update(); @@ -218,7 +218,7 @@ void BaseButton::set_pressed(bool p_pressed) { if (p_pressed) { _unpress_group(); if (button_group.is_valid()) { - button_group->emit_signal("pressed", this); + button_group->emit_signal(SNAME("pressed"), this); } } _toggled(status.pressed); -- cgit v1.2.3