Skip to content

Commit 091212b

Browse files
committed
Merge pull request godotengine#93602 from aaronp64/inspector_latency
Improve Editor Inspector/Theme item lookup performance
2 parents 3b81db3 + 7593e55 commit 091212b

File tree

16 files changed

+141
-116
lines changed

16 files changed

+141
-116
lines changed

core/object/class_db.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,29 @@ StringName ClassDB::get_parent_class_nocheck(const StringName &p_class) {
303303
return ti->inherits;
304304
}
305305

306+
bool ClassDB::get_inheritance_chain_nocheck(const StringName &p_class, Vector<StringName> &r_result) {
307+
OBJTYPE_RLOCK;
308+
309+
ClassInfo *start = classes.getptr(p_class);
310+
if (!start) {
311+
return false;
312+
}
313+
314+
int classes_to_add = 0;
315+
for (ClassInfo *ti = start; ti; ti = ti->inherits_ptr) {
316+
classes_to_add++;
317+
}
318+
319+
int64_t old_size = r_result.size();
320+
r_result.resize(old_size + classes_to_add);
321+
StringName *w = r_result.ptrw() + old_size;
322+
for (ClassInfo *ti = start; ti; ti = ti->inherits_ptr) {
323+
*w++ = ti->name;
324+
}
325+
326+
return true;
327+
}
328+
306329
StringName ClassDB::get_compatibility_remapped_class(const StringName &p_class) {
307330
if (classes.has(p_class)) {
308331
return p_class;

core/object/class_db.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ class ClassDB {
282282
static void get_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes);
283283
static void get_direct_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes);
284284
static StringName get_parent_class_nocheck(const StringName &p_class);
285+
static bool get_inheritance_chain_nocheck(const StringName &p_class, Vector<StringName> &r_result);
285286
static StringName get_parent_class(const StringName &p_class);
286287
static StringName get_compatibility_remapped_class(const StringName &p_class);
287288
static bool class_exists(const StringName &p_class);

editor/editor_node.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ void EditorNode::_update_theme(bool p_skip_creation) {
511511
DisplayServer::set_early_window_clear_color_override(true, theme->get_color(SNAME("background"), EditorStringName(Editor)));
512512
}
513513

514-
List<Ref<Theme>> editor_themes;
514+
Vector<Ref<Theme>> editor_themes;
515515
editor_themes.push_back(theme);
516516
editor_themes.push_back(ThemeDB::get_singleton()->get_default_theme());
517517

@@ -580,7 +580,7 @@ void EditorNode::update_preview_themes(int p_mode) {
580580
return; // Too early.
581581
}
582582

583-
List<Ref<Theme>> preview_themes;
583+
Vector<Ref<Theme>> preview_themes;
584584

585585
switch (p_mode) {
586586
case CanvasItemEditor::THEME_PREVIEW_PROJECT:

editor/plugins/theme_editor_preview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void ThemeEditorPreview::_notification(int p_what) {
205205
} break;
206206

207207
case NOTIFICATION_READY: {
208-
List<Ref<Theme>> preview_themes;
208+
Vector<Ref<Theme>> preview_themes;
209209
preview_themes.push_back(ThemeDB::get_singleton()->get_default_theme());
210210
ThemeDB::get_singleton()->create_theme_context(preview_root, preview_themes);
211211
} break;

editor/project_manager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ void ProjectManager::_update_theme(bool p_skip_creation) {
190190
DisplayServer::set_early_window_clear_color_override(true, theme->get_color(SNAME("background"), EditorStringName(Editor)));
191191
}
192192

193-
List<Ref<Theme>> editor_themes;
193+
Vector<Ref<Theme>> editor_themes;
194194
editor_themes.push_back(theme);
195195
editor_themes.push_back(ThemeDB::get_singleton()->get_default_theme());
196196

scene/3d/label_3d.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -797,13 +797,13 @@ Ref<Font> Label3D::_get_font_or_default() const {
797797
}
798798

799799
const StringName theme_name = SceneStringName(font);
800-
List<StringName> theme_types;
801-
ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), &theme_types);
800+
Vector<StringName> theme_types;
801+
ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), theme_types);
802802

803803
ThemeContext *global_context = ThemeDB::get_singleton()->get_default_theme_context();
804-
List<Ref<Theme>> themes = global_context->get_themes();
804+
Vector<Ref<Theme>> themes = global_context->get_themes();
805805
if (Engine::get_singleton()->is_editor_hint()) {
806-
themes.push_front(ThemeDB::get_singleton()->get_project_theme());
806+
themes.insert(0, ThemeDB::get_singleton()->get_project_theme());
807807
}
808808

809809
for (const Ref<Theme> &theme : themes) {

scene/gui/control.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,8 +2577,8 @@ Ref<Texture2D> Control::get_theme_icon(const StringName &p_name, const StringNam
25772577
return data.theme_icon_cache[p_theme_type][p_name];
25782578
}
25792579

2580-
List<StringName> theme_types;
2581-
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2580+
Vector<StringName> theme_types;
2581+
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
25822582
Ref<Texture2D> icon = data.theme_owner->get_theme_item_in_types(Theme::DATA_TYPE_ICON, p_name, theme_types);
25832583
data.theme_icon_cache[p_theme_type][p_name] = icon;
25842584
return icon;
@@ -2601,8 +2601,8 @@ Ref<StyleBox> Control::get_theme_stylebox(const StringName &p_name, const String
26012601
return data.theme_style_cache[p_theme_type][p_name];
26022602
}
26032603

2604-
List<StringName> theme_types;
2605-
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2604+
Vector<StringName> theme_types;
2605+
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
26062606
Ref<StyleBox> style = data.theme_owner->get_theme_item_in_types(Theme::DATA_TYPE_STYLEBOX, p_name, theme_types);
26072607
data.theme_style_cache[p_theme_type][p_name] = style;
26082608
return style;
@@ -2625,8 +2625,8 @@ Ref<Font> Control::get_theme_font(const StringName &p_name, const StringName &p_
26252625
return data.theme_font_cache[p_theme_type][p_name];
26262626
}
26272627

2628-
List<StringName> theme_types;
2629-
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2628+
Vector<StringName> theme_types;
2629+
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
26302630
Ref<Font> font = data.theme_owner->get_theme_item_in_types(Theme::DATA_TYPE_FONT, p_name, theme_types);
26312631
data.theme_font_cache[p_theme_type][p_name] = font;
26322632
return font;
@@ -2649,8 +2649,8 @@ int Control::get_theme_font_size(const StringName &p_name, const StringName &p_t
26492649
return data.theme_font_size_cache[p_theme_type][p_name];
26502650
}
26512651

2652-
List<StringName> theme_types;
2653-
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2652+
Vector<StringName> theme_types;
2653+
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
26542654
int font_size = data.theme_owner->get_theme_item_in_types(Theme::DATA_TYPE_FONT_SIZE, p_name, theme_types);
26552655
data.theme_font_size_cache[p_theme_type][p_name] = font_size;
26562656
return font_size;
@@ -2673,8 +2673,8 @@ Color Control::get_theme_color(const StringName &p_name, const StringName &p_the
26732673
return data.theme_color_cache[p_theme_type][p_name];
26742674
}
26752675

2676-
List<StringName> theme_types;
2677-
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2676+
Vector<StringName> theme_types;
2677+
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
26782678
Color color = data.theme_owner->get_theme_item_in_types(Theme::DATA_TYPE_COLOR, p_name, theme_types);
26792679
data.theme_color_cache[p_theme_type][p_name] = color;
26802680
return color;
@@ -2697,8 +2697,8 @@ int Control::get_theme_constant(const StringName &p_name, const StringName &p_th
26972697
return data.theme_constant_cache[p_theme_type][p_name];
26982698
}
26992699

2700-
List<StringName> theme_types;
2701-
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2700+
Vector<StringName> theme_types;
2701+
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
27022702
int constant = data.theme_owner->get_theme_item_in_types(Theme::DATA_TYPE_CONSTANT, p_name, theme_types);
27032703
data.theme_constant_cache[p_theme_type][p_name] = constant;
27042704
return constant;
@@ -2743,8 +2743,8 @@ bool Control::has_theme_icon(const StringName &p_name, const StringName &p_theme
27432743
}
27442744
}
27452745

2746-
List<StringName> theme_types;
2747-
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2746+
Vector<StringName> theme_types;
2747+
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
27482748
return data.theme_owner->has_theme_item_in_types(Theme::DATA_TYPE_ICON, p_name, theme_types);
27492749
}
27502750

@@ -2760,8 +2760,8 @@ bool Control::has_theme_stylebox(const StringName &p_name, const StringName &p_t
27602760
}
27612761
}
27622762

2763-
List<StringName> theme_types;
2764-
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2763+
Vector<StringName> theme_types;
2764+
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
27652765
return data.theme_owner->has_theme_item_in_types(Theme::DATA_TYPE_STYLEBOX, p_name, theme_types);
27662766
}
27672767

@@ -2777,8 +2777,8 @@ bool Control::has_theme_font(const StringName &p_name, const StringName &p_theme
27772777
}
27782778
}
27792779

2780-
List<StringName> theme_types;
2781-
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2780+
Vector<StringName> theme_types;
2781+
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
27822782
return data.theme_owner->has_theme_item_in_types(Theme::DATA_TYPE_FONT, p_name, theme_types);
27832783
}
27842784

@@ -2794,8 +2794,8 @@ bool Control::has_theme_font_size(const StringName &p_name, const StringName &p_
27942794
}
27952795
}
27962796

2797-
List<StringName> theme_types;
2798-
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2797+
Vector<StringName> theme_types;
2798+
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
27992799
return data.theme_owner->has_theme_item_in_types(Theme::DATA_TYPE_FONT_SIZE, p_name, theme_types);
28002800
}
28012801

@@ -2811,8 +2811,8 @@ bool Control::has_theme_color(const StringName &p_name, const StringName &p_them
28112811
}
28122812
}
28132813

2814-
List<StringName> theme_types;
2815-
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2814+
Vector<StringName> theme_types;
2815+
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
28162816
return data.theme_owner->has_theme_item_in_types(Theme::DATA_TYPE_COLOR, p_name, theme_types);
28172817
}
28182818

@@ -2828,8 +2828,8 @@ bool Control::has_theme_constant(const StringName &p_name, const StringName &p_t
28282828
}
28292829
}
28302830

2831-
List<StringName> theme_types;
2832-
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2831+
Vector<StringName> theme_types;
2832+
data.theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
28332833
return data.theme_owner->has_theme_item_in_types(Theme::DATA_TYPE_CONSTANT, p_name, theme_types);
28342834
}
28352835

scene/main/window.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,8 +2149,8 @@ Ref<Texture2D> Window::get_theme_icon(const StringName &p_name, const StringName
21492149
return theme_icon_cache[p_theme_type][p_name];
21502150
}
21512151

2152-
List<StringName> theme_types;
2153-
theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2152+
Vector<StringName> theme_types;
2153+
theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
21542154
Ref<Texture2D> icon = theme_owner->get_theme_item_in_types(Theme::DATA_TYPE_ICON, p_name, theme_types);
21552155
theme_icon_cache[p_theme_type][p_name] = icon;
21562156
return icon;
@@ -2173,8 +2173,8 @@ Ref<StyleBox> Window::get_theme_stylebox(const StringName &p_name, const StringN
21732173
return theme_style_cache[p_theme_type][p_name];
21742174
}
21752175

2176-
List<StringName> theme_types;
2177-
theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2176+
Vector<StringName> theme_types;
2177+
theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
21782178
Ref<StyleBox> style = theme_owner->get_theme_item_in_types(Theme::DATA_TYPE_STYLEBOX, p_name, theme_types);
21792179
theme_style_cache[p_theme_type][p_name] = style;
21802180
return style;
@@ -2197,8 +2197,8 @@ Ref<Font> Window::get_theme_font(const StringName &p_name, const StringName &p_t
21972197
return theme_font_cache[p_theme_type][p_name];
21982198
}
21992199

2200-
List<StringName> theme_types;
2201-
theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2200+
Vector<StringName> theme_types;
2201+
theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
22022202
Ref<Font> font = theme_owner->get_theme_item_in_types(Theme::DATA_TYPE_FONT, p_name, theme_types);
22032203
theme_font_cache[p_theme_type][p_name] = font;
22042204
return font;
@@ -2221,8 +2221,8 @@ int Window::get_theme_font_size(const StringName &p_name, const StringName &p_th
22212221
return theme_font_size_cache[p_theme_type][p_name];
22222222
}
22232223

2224-
List<StringName> theme_types;
2225-
theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2224+
Vector<StringName> theme_types;
2225+
theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
22262226
int font_size = theme_owner->get_theme_item_in_types(Theme::DATA_TYPE_FONT_SIZE, p_name, theme_types);
22272227
theme_font_size_cache[p_theme_type][p_name] = font_size;
22282228
return font_size;
@@ -2245,8 +2245,8 @@ Color Window::get_theme_color(const StringName &p_name, const StringName &p_them
22452245
return theme_color_cache[p_theme_type][p_name];
22462246
}
22472247

2248-
List<StringName> theme_types;
2249-
theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2248+
Vector<StringName> theme_types;
2249+
theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
22502250
Color color = theme_owner->get_theme_item_in_types(Theme::DATA_TYPE_COLOR, p_name, theme_types);
22512251
theme_color_cache[p_theme_type][p_name] = color;
22522252
return color;
@@ -2269,8 +2269,8 @@ int Window::get_theme_constant(const StringName &p_name, const StringName &p_the
22692269
return theme_constant_cache[p_theme_type][p_name];
22702270
}
22712271

2272-
List<StringName> theme_types;
2273-
theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2272+
Vector<StringName> theme_types;
2273+
theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
22742274
int constant = theme_owner->get_theme_item_in_types(Theme::DATA_TYPE_CONSTANT, p_name, theme_types);
22752275
theme_constant_cache[p_theme_type][p_name] = constant;
22762276
return constant;
@@ -2315,8 +2315,8 @@ bool Window::has_theme_icon(const StringName &p_name, const StringName &p_theme_
23152315
}
23162316
}
23172317

2318-
List<StringName> theme_types;
2319-
theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2318+
Vector<StringName> theme_types;
2319+
theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
23202320
return theme_owner->has_theme_item_in_types(Theme::DATA_TYPE_ICON, p_name, theme_types);
23212321
}
23222322

@@ -2332,8 +2332,8 @@ bool Window::has_theme_stylebox(const StringName &p_name, const StringName &p_th
23322332
}
23332333
}
23342334

2335-
List<StringName> theme_types;
2336-
theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2335+
Vector<StringName> theme_types;
2336+
theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
23372337
return theme_owner->has_theme_item_in_types(Theme::DATA_TYPE_STYLEBOX, p_name, theme_types);
23382338
}
23392339

@@ -2349,8 +2349,8 @@ bool Window::has_theme_font(const StringName &p_name, const StringName &p_theme_
23492349
}
23502350
}
23512351

2352-
List<StringName> theme_types;
2353-
theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2352+
Vector<StringName> theme_types;
2353+
theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
23542354
return theme_owner->has_theme_item_in_types(Theme::DATA_TYPE_FONT, p_name, theme_types);
23552355
}
23562356

@@ -2366,8 +2366,8 @@ bool Window::has_theme_font_size(const StringName &p_name, const StringName &p_t
23662366
}
23672367
}
23682368

2369-
List<StringName> theme_types;
2370-
theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2369+
Vector<StringName> theme_types;
2370+
theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
23712371
return theme_owner->has_theme_item_in_types(Theme::DATA_TYPE_FONT_SIZE, p_name, theme_types);
23722372
}
23732373

@@ -2383,8 +2383,8 @@ bool Window::has_theme_color(const StringName &p_name, const StringName &p_theme
23832383
}
23842384
}
23852385

2386-
List<StringName> theme_types;
2387-
theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2386+
Vector<StringName> theme_types;
2387+
theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
23882388
return theme_owner->has_theme_item_in_types(Theme::DATA_TYPE_COLOR, p_name, theme_types);
23892389
}
23902390

@@ -2400,8 +2400,8 @@ bool Window::has_theme_constant(const StringName &p_name, const StringName &p_th
24002400
}
24012401
}
24022402

2403-
List<StringName> theme_types;
2404-
theme_owner->get_theme_type_dependencies(this, p_theme_type, &theme_types);
2403+
Vector<StringName> theme_types;
2404+
theme_owner->get_theme_type_dependencies(this, p_theme_type, theme_types);
24052405
return theme_owner->has_theme_item_in_types(Theme::DATA_TYPE_CONSTANT, p_name, theme_types);
24062406
}
24072407

scene/resources/3d/primitive_meshes.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3476,13 +3476,13 @@ Ref<Font> TextMesh::_get_font_or_default() const {
34763476
}
34773477

34783478
StringName theme_name = "font";
3479-
List<StringName> theme_types;
3480-
ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), &theme_types);
3479+
Vector<StringName> theme_types;
3480+
ThemeDB::get_singleton()->get_native_type_dependencies(get_class_name(), theme_types);
34813481

34823482
ThemeContext *global_context = ThemeDB::get_singleton()->get_default_theme_context();
3483-
List<Ref<Theme>> themes = global_context->get_themes();
3483+
Vector<Ref<Theme>> themes = global_context->get_themes();
34843484
if (Engine::get_singleton()->is_editor_hint()) {
3485-
themes.push_front(ThemeDB::get_singleton()->get_project_theme());
3485+
themes.insert(0, ThemeDB::get_singleton()->get_project_theme());
34863486
}
34873487

34883488
for (const Ref<Theme> &theme : themes) {

0 commit comments

Comments
 (0)