-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add EditorStringNames singleton #80573
Add EditorStringNames singleton #80573
Conversation
c79a212
to
d48613a
Compare
d48613a
to
7cbb462
Compare
7cbb462
to
4759283
Compare
BenchmarkStartup/shutdown times❯ hyperfine -iw1 "bin/godot.linuxbsd.editor.x86_64 --quit" "bin/godot.linuxbsd.editor.x86_64.master --quit"
Benchmark 1: bin/godot.linuxbsd.editor.x86_64 --quit (this PR)
Time (mean ± σ): 2.740 s ± 0.056 s [User: 1.390 s, System: 0.225 s]
Range (min … max): 2.619 s … 2.841 s 10 runs
Benchmark 2: bin/godot.linuxbsd.editor.x86_64.master --quit
Time (mean ± σ): 2.690 s ± 0.066 s [User: 1.394 s, System: 0.220 s]
Range (min … max): 2.591 s … 2.768 s 10 runs
Summary
bin/godot.linuxbsd.editor.x86_64.master --quit ran
1.02 ± 0.03 times faster than bin/godot.linuxbsd.editor.x86_64 --quit
❯ hyperfine -iw1 "bin/godot.linuxbsd.editor.x86_64 /tmp/4/project.godot --quit" "bin/godot.linuxbsd.editor.x86_64.master /tmp/4/project.godot --quit"
Benchmark 1: bin/godot.linuxbsd.editor.x86_64 /tmp/4/project.godot --quit (this PR)
Time (mean ± σ): 4.768 s ± 0.425 s [User: 3.847 s, System: 0.380 s]
Range (min … max): 4.169 s … 5.171 s 10 runs
Benchmark 2: bin/godot.linuxbsd.editor.x86_64.master /tmp/4/project.godot --quit
Time (mean ± σ): 4.808 s ± 0.376 s [User: 3.851 s, System: 0.388 s]
Range (min … max): 4.402 s … 5.173 s 10 runs
Summary
bin/godot.linuxbsd.editor.x86_64 /tmp/4/project.godot --quit ran
1.01 ± 0.12 times faster than bin/godot.linuxbsd.editor.x86_64.master /tmp/4/project.godot --quit No meaningful difference, outside of margin of error. Binary sizeStripped Linux x86_64 editor binary (
That's a reduction of 350 KB, nice 🙂 Peak memory usageAverage of 3 runs after a warmup run, opening editor on empty project then quitting: # Measured using: /usr/bin/time -f "%M" bin/godot.linuxbsd.editor.x86_64 /tmp/4/project.godot --quit
829,358,000 godot.linuxbsd.editor.x86_64 (this PR)
829,777,000 godot.linuxbsd.editor.x86_64.master Memory usage seems just a tad lower, but it may be within margin of error (each run has slightly different peak memory usage, ±0.1 %). sharkdp/hyperfine#86 could help us get more reliable benchmarking if it's implemented 🙂 |
4759283
to
74fb37b
Compare
74fb37b
to
156a960
Compare
6d7c6f1
to
7e13297
Compare
editor/editor_node.cpp
Outdated
} else if (singleton->gui_base->has_theme_icon(p_editor->get_name(), SNAME("EditorIcons"))) { | ||
tb->set_icon(singleton->gui_base->get_theme_icon(p_editor->get_name(), SNAME("EditorIcons"))); | ||
} else if (singleton->gui_base->has_theme_icon(p_editor->get_name(), EditorStringName(EditorIcons))) { | ||
tb->set_icon(singleton->gui_base->get_editor_theme_icon("")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this actually get the correct icon with just "" as the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I autoreplaced all occurrences with the new method and seems like some of them are broken now .-.
I guess I should double-check all changed lines.
06c3429
to
c952376
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this might need a restart and the search/replace applied more carefully
Not an exhaustive list
c952376
to
61b7fb7
Compare
I used a script to do that. I don't see any other way to do a non-trivial replacement in 1600+ lines. Luckily GitHub's diff makes it easy to spot wrong replacements. It's still 176 files though -_- |
Meant to check different cases in the replace script, one of the issues was probably caused by greedy search, as it grabbed all between quotes somehow |
I'd say to use a regex to replace all the trivial cases, checking that it's exactly a string in the area, and then use some search method to identify all the cases that aren't trivial So strictly replace |
61b7fb7
to
ab47f2f
Compare
ab47f2f
to
6de34fd
Compare
@@ -158,7 +159,7 @@ void EditorVisualProfiler::_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("dark_color_2", EditorStringName(Editor)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's always tricky with these to understand if SNAME is skipped on purpose here or by mistake. 😕 Feel free to leave it as is, there are probably many more of these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to not add or remove existing SNAMEs, as it's unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't check every file, and I think you've already identified and fixed some automation issues together. So assuming it's clean now, I'm going to approve this. (I skimmed through a few still.)
It's definitely an improvement for icons with the new method. For the rest, especially given Calinou's testing, I'm not so sure. It doesn't really improve code clarity, IMO. But it doesn't make it worse either. Perhaps we could add dedicated methods for all data types?
I'm also working on a system to declare theme items per class which, together with theme cache, should reduce the need for this. But I think we can go for it for now.
Thanks! Now rebasing begins 😬 |
This PR adds EditorStringNames singleton, complementary to CoreStringNames and SceneStringNames. It includes some most common theme-related StringNames:
Editor
,EditorFonts
,EditorIcons
andEditorStyles
. More strings can be added later (e.g. most common types or most common constant/stylebox names etc.).This results in lower memory usage of the editor (I didn't do any benchmark though) and slightly better performance in some cases (especially initializing the theme might be faster I think).
I also included a macro
EditorStringName(name)
, which is a shorthand forEditorStringNames::get_singleton()->name
, making the code much less verbose. We could add such macro to other StringName singletons too.