Removed redundant ClassDB::is_class_enabled() and moved second dynamic_cast inside worst case if

(cherry picked from commit b6cfc55113)
This commit is contained in:
Bartłomiej T. Listwon 2022-01-08 14:02:43 +01:00 committed by Rémi Verschelde
parent 27fc50d54a
commit 58c460b3b7
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -175,14 +175,12 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
#endif
}
} else {
Object *obj = nullptr;
//node belongs to this scene and must be created
Object *obj = ClassDB::instance(snames[n.type]);
if (ClassDB::is_class_enabled(snames[n.type])) {
//node belongs to this scene and must be created
obj = ClassDB::instance(snames[n.type]);
}
node = Object::cast_to<Node>(obj);
if (!Object::cast_to<Node>(obj)) {
if (!node) {
if (obj) {
memdelete(obj);
obj = nullptr;
@ -201,9 +199,9 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
if (!obj) {
obj = memnew(Node);
}
}
node = Object::cast_to<Node>(obj);
node = Object::cast_to<Node>(obj);
}
}
if (node) {