Improve ClassDB::_is_parent_class performance

Change ClassDB::_is_parent_class to use ClassInfo::inherits_ptr, instead of looking up each inherited class name.
This commit is contained in:
aaronp64 2024-08-08 13:16:42 -04:00
parent 33fe10c065
commit 6e5175592d

View file

@ -227,16 +227,12 @@ public:
#endif #endif
bool ClassDB::_is_parent_class(const StringName &p_class, const StringName &p_inherits) { bool ClassDB::_is_parent_class(const StringName &p_class, const StringName &p_inherits) {
if (!classes.has(p_class)) { ClassInfo *c = classes.getptr(p_class);
return false; while (c) {
} if (c->name == p_inherits) {
StringName inherits = p_class;
while (inherits.operator String().length()) {
if (inherits == p_inherits) {
return true; return true;
} }
inherits = _get_parent_class(inherits); c = c->inherits_ptr;
} }
return false; return false;