summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-09-12 09:17:39 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-09-12 09:17:39 +0200
commitcd9da3344f5db4cea5af43ddeeba9629cdc538e2 (patch)
treed1df1eb32c97c26dc64c166fec42a130c24d3dcc /core
parentf5bf9b60bd0ac876c35e0f4ace171b75ad68e889 (diff)
parent6e5175592de2b8756062752b0a73d724ae496ca1 (diff)
downloadredot-engine-cd9da3344f5db4cea5af43ddeeba9629cdc538e2.tar.gz
Merge pull request #95292 from aaronp64/is_parent_class_perf
Improve `ClassDB::_is_parent_class` performance
Diffstat (limited to 'core')
-rw-r--r--core/object/class_db.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp
index a65411629f..ee8c469515 100644
--- a/core/object/class_db.cpp
+++ b/core/object/class_db.cpp
@@ -227,16 +227,12 @@ public:
#endif
bool ClassDB::_is_parent_class(const StringName &p_class, const StringName &p_inherits) {
- if (!classes.has(p_class)) {
- return false;
- }
-
- StringName inherits = p_class;
- while (inherits.operator String().length()) {
- if (inherits == p_inherits) {
+ ClassInfo *c = classes.getptr(p_class);
+ while (c) {
+ if (c->name == p_inherits) {
return true;
}
- inherits = _get_parent_class(inherits);
+ c = c->inherits_ptr;
}
return false;