mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 06:11:29 +03:00
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.
This commit is contained in:
@@ -135,11 +135,11 @@ String EditorProfiler::_get_time_as_text(const Metric &m, float p_time, int p_ca
|
||||
}
|
||||
|
||||
Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) const {
|
||||
Color bc = get_theme_color("error_color", "Editor");
|
||||
Color bc = get_theme_color(SNAME("error_color"), SNAME("Editor"));
|
||||
double rot = ABS(double(p_signature.hash()) / double(0x7FFFFFFF));
|
||||
Color c;
|
||||
c.set_hsv(rot, bc.get_s(), bc.get_v());
|
||||
return c.lerp(get_theme_color("base_color", "Editor"), 0.07);
|
||||
return c.lerp(get_theme_color(SNAME("base_color"), SNAME("Editor")), 0.07);
|
||||
}
|
||||
|
||||
void EditorProfiler::_item_edited() {
|
||||
@@ -180,7 +180,7 @@ void EditorProfiler::_update_plot() {
|
||||
}
|
||||
|
||||
uint8_t *wr = graph_image.ptrw();
|
||||
const Color background_color = get_theme_color("dark_color_2", "Editor");
|
||||
const Color background_color = get_theme_color(SNAME("dark_color_2"), SNAME("Editor"));
|
||||
|
||||
// Clear the previous frame and set the background color.
|
||||
for (int i = 0; i < desired_len; i += 4) {
|
||||
@@ -376,14 +376,14 @@ void EditorProfiler::_update_frame() {
|
||||
|
||||
void EditorProfiler::_activate_pressed() {
|
||||
if (activate->is_pressed()) {
|
||||
activate->set_icon(get_theme_icon("Stop", "EditorIcons"));
|
||||
activate->set_icon(get_theme_icon(SNAME("Stop"), SNAME("EditorIcons")));
|
||||
activate->set_text(TTR("Stop"));
|
||||
_clear_pressed();
|
||||
} else {
|
||||
activate->set_icon(get_theme_icon("Play", "EditorIcons"));
|
||||
activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
|
||||
activate->set_text(TTR("Start"));
|
||||
}
|
||||
emit_signal("enable_profiling", activate->is_pressed());
|
||||
emit_signal(SNAME("enable_profiling"), activate->is_pressed());
|
||||
}
|
||||
|
||||
void EditorProfiler::_clear_pressed() {
|
||||
@@ -394,8 +394,8 @@ void EditorProfiler::_clear_pressed() {
|
||||
|
||||
void EditorProfiler::_notification(int p_what) {
|
||||
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_LAYOUT_DIRECTION_CHANGED || p_what == NOTIFICATION_TRANSLATION_CHANGED) {
|
||||
activate->set_icon(get_theme_icon("Play", "EditorIcons"));
|
||||
clear_button->set_icon(get_theme_icon("Clear", "EditorIcons"));
|
||||
activate->set_icon(get_theme_icon(SNAME("Play"), SNAME("EditorIcons")));
|
||||
clear_button->set_icon(get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,7 +462,7 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
|
||||
|
||||
if (activate->is_pressed()) {
|
||||
if (!seeking) {
|
||||
emit_signal("break_request");
|
||||
emit_signal(SNAME("break_request"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user