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. --- editor/editor_autoload_settings.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'editor/editor_autoload_settings.cpp') diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index 12ae55fbc1..c6d52107cd 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -53,12 +53,12 @@ void EditorAutoloadSettings::_notification(int p_what) { for (List::Element *E = autoload_cache.front(); E; E = E->next()) { AutoLoadInfo &info = E->get(); if (info.node && info.in_editor) { - get_tree()->get_root()->call_deferred("add_child", info.node); + get_tree()->get_root()->call_deferred(SNAME("add_child"), info.node); } } - browse_button->set_icon(get_theme_icon("Folder", "EditorIcons")); + browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } else if (p_what == NOTIFICATION_THEME_CHANGED) { - browse_button->set_icon(get_theme_icon("Folder", "EditorIcons")); + browse_button->set_icon(get_theme_icon(SNAME("Folder"), SNAME("EditorIcons"))); } } @@ -453,10 +453,10 @@ void EditorAutoloadSettings::update_autoload() { item->set_editable(2, true); item->set_text(2, TTR("Enable")); item->set_checked(2, info.is_singleton); - item->add_button(3, get_theme_icon("Load", "EditorIcons"), BUTTON_OPEN); - item->add_button(3, get_theme_icon("MoveUp", "EditorIcons"), BUTTON_MOVE_UP); - item->add_button(3, get_theme_icon("MoveDown", "EditorIcons"), BUTTON_MOVE_DOWN); - item->add_button(3, get_theme_icon("Remove", "EditorIcons"), BUTTON_DELETE); + item->add_button(3, get_theme_icon(SNAME("Load"), SNAME("EditorIcons")), BUTTON_OPEN); + item->add_button(3, get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), BUTTON_MOVE_UP); + item->add_button(3, get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")), BUTTON_MOVE_DOWN); + item->add_button(3, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_DELETE); item->set_selectable(3, false); } @@ -470,7 +470,7 @@ void EditorAutoloadSettings::update_autoload() { } if (info.in_editor) { ERR_CONTINUE(!info.node); - get_tree()->get_root()->call_deferred("remove_child", info.node); + get_tree()->get_root()->call_deferred(SNAME("remove_child"), info.node); } if (info.node) { @@ -914,7 +914,7 @@ EditorAutoloadSettings::~EditorAutoloadSettings() { void EditorAutoloadSettings::_set_autoload_add_path(const String &p_text) { autoload_add_path->set_text(p_text); - autoload_add_path->emit_signal("text_submitted", p_text); + autoload_add_path->emit_signal(SNAME("text_submitted"), p_text); } void EditorAutoloadSettings::_browse_autoload_add_path() { -- cgit v1.2.3