diff options
author | aaronp64 <aaronp.code@gmail.com> | 2024-08-08 13:16:42 -0400 |
---|---|---|
committer | aaronp64 <aaronp.code@gmail.com> | 2024-08-08 13:16:42 -0400 |
commit | 6e5175592de2b8756062752b0a73d724ae496ca1 (patch) | |
tree | 54207c2f399a2741fff34132a514045a8047941e /core | |
parent | 33fe10c065d194b2a440a883ecdc6a71fd3fbd5f (diff) | |
download | redot-engine-6e5175592de2b8756062752b0a73d724ae496ca1.tar.gz |
Improve ClassDB::_is_parent_class performance
Change ClassDB::_is_parent_class to use ClassInfo::inherits_ptr, instead of looking up each inherited class name.
Diffstat (limited to 'core')
-rw-r--r-- | core/object/class_db.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index ceeb04b8ea..7abf23aaeb 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; |