Skip to content

Commit

Permalink
Improve ContainerTypeValidate performance for object types
Browse files Browse the repository at this point in the history
Use const reference for class name instead of copying, to avoid some extra reference counting overhead
  • Loading branch information
aaronp64 committed Dec 5, 2024
1 parent 1f47e4c commit b19ebba
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/variant/container_type_validate.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ struct ContainerTypeValidate {
return true; // All good, no class type requested.
}

StringName obj_class = object->get_class_name();
const StringName &obj_class = object->get_class_name();
if (obj_class != class_name) {
ERR_FAIL_COND_V_MSG(!ClassDB::is_parent_class(object->get_class_name(), class_name), false, vformat("Attempted to %s an object of type '%s' into a %s, which does not inherit from '%s'.", String(p_operation), object->get_class(), where, String(class_name)));
ERR_FAIL_COND_V_MSG(!ClassDB::is_parent_class(obj_class, class_name), false, vformat("Attempted to %s an object of type '%s' into a %s, which does not inherit from '%s'.", String(p_operation), object->get_class(), where, String(class_name)));
}

if (script.is_null()) {
Expand Down

0 comments on commit b19ebba

Please sign in to comment.