From b19ebbacb2948f63dd617dc65a367ffa69365329 Mon Sep 17 00:00:00 2001 From: aaronp64 Date: Thu, 5 Dec 2024 11:16:43 -0500 Subject: [PATCH] Improve ContainerTypeValidate performance for object types Use const reference for class name instead of copying, to avoid some extra reference counting overhead --- core/variant/container_type_validate.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/variant/container_type_validate.h b/core/variant/container_type_validate.h index 8971fadf732..adfeaed19c0 100644 --- a/core/variant/container_type_validate.h +++ b/core/variant/container_type_validate.h @@ -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()) {