Skip to content

Commit 6e51755

Browse files
committed
Improve ClassDB::_is_parent_class performance
Change ClassDB::_is_parent_class to use ClassInfo::inherits_ptr, instead of looking up each inherited class name.
1 parent 33fe10c commit 6e51755

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

core/object/class_db.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,12 @@ class PlaceholderExtensionInstance {
227227
#endif
228228

229229
bool ClassDB::_is_parent_class(const StringName &p_class, const StringName &p_inherits) {
230-
if (!classes.has(p_class)) {
231-
return false;
232-
}
233-
234-
StringName inherits = p_class;
235-
while (inherits.operator String().length()) {
236-
if (inherits == p_inherits) {
230+
ClassInfo *c = classes.getptr(p_class);
231+
while (c) {
232+
if (c->name == p_inherits) {
237233
return true;
238234
}
239-
inherits = _get_parent_class(inherits);
235+
c = c->inherits_ptr;
240236
}
241237

242238
return false;

0 commit comments

Comments
 (0)