summaryrefslogtreecommitdiffstats
path: root/core/object
diff options
context:
space:
mode:
authoraaronp64 <aaronp.code@gmail.com>2024-06-24 10:09:20 -0400
committeraaronp64 <aaronp.code@gmail.com>2024-08-20 13:39:40 -0400
commit7593e55527177d0dfb5ad536330b50e272bd93d4 (patch)
tree409a1b5f9ac9c58040e3e5261df1f7bc14234dd1 /core/object
parent6b281c0c07b07f2142b1fc8a6b3158091a9b124c (diff)
downloadredot-engine-7593e55527177d0dfb5ad536330b50e272bd93d4.tar.gz
Improve Editor Inspector/Theme item lookup performance
Changes to reduce the latency between changing node selection in the editor and seeing the new node reflected in the Inspector tab - Use Vector instead of List for ThemeOwner::get_theme_type_dependencies and related functions - Use Vector instead of List for ThemeContext::themes, set_themes(), and get_themes() - Add ClassDB:get_inheritance_chain_nocheck to get all parent/ancestor classes at once, to avoid repeated ClassDB locking overhead - Update BIND_THEME_ITEM macros and ThemeDB::update_class_instance_items to use provided StringNames for call to ThemeItemSetter, instead of creating a new StringName in each call These changes reduce the time taken by EditorInspector::update_tree by around 30-35%
Diffstat (limited to 'core/object')
-rw-r--r--core/object/class_db.cpp23
-rw-r--r--core/object/class_db.h1
2 files changed, 24 insertions, 0 deletions
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index fe4345aa0d..4e52bb3872 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -291,6 +291,29 @@ StringName ClassDB::get_parent_class_nocheck(const StringName &p_class) {
return ti->inherits;
}
+bool ClassDB::get_inheritance_chain_nocheck(const StringName &p_class, Vector<StringName> &r_result) {
+ OBJTYPE_RLOCK;
+
+ ClassInfo *start = classes.getptr(p_class);
+ if (!start) {
+ return false;
+ }
+
+ int classes_to_add = 0;
+ for (ClassInfo *ti = start; ti; ti = ti->inherits_ptr) {
+ classes_to_add++;
+ }
+
+ int64_t old_size = r_result.size();
+ r_result.resize(old_size + classes_to_add);
+ StringName *w = r_result.ptrw() + old_size;
+ for (ClassInfo *ti = start; ti; ti = ti->inherits_ptr) {
+ *w++ = ti->name;
+ }
+
+ return true;
+}
+
StringName ClassDB::get_compatibility_remapped_class(const StringName &p_class) {
if (classes.has(p_class)) {
return p_class;
diff --git a/core/object/class_db.h b/core/object/class_db.h
index 37a864c109..9e0f860a9b 100644
--- a/core/object/class_db.h
+++ b/core/object/class_db.h
@@ -282,6 +282,7 @@ public:
static void get_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes);
static void get_direct_inheriters_from_class(const StringName &p_class, List<StringName> *p_classes);
static StringName get_parent_class_nocheck(const StringName &p_class);
+ static bool get_inheritance_chain_nocheck(const StringName &p_class, Vector<StringName> &r_result);
static StringName get_parent_class(const StringName &p_class);
static StringName get_compatibility_remapped_class(const StringName &p_class);
static bool class_exists(const StringName &p_class);