From 0fe5be352558c487e24724fca4c2cb9f53a724e6 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 18 Feb 2021 12:40:27 +0100 Subject: Cleanup: return const reference instead of copy There isn't really a reason for why this has to return a copy of the data instead of a reference. --- source/blender/functions/FN_generic_value_map.hh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'source/blender/functions') diff --git a/source/blender/functions/FN_generic_value_map.hh b/source/blender/functions/FN_generic_value_map.hh index a9f2dc8a868..68cb945f1af 100644 --- a/source/blender/functions/FN_generic_value_map.hh +++ b/source/blender/functions/FN_generic_value_map.hh @@ -104,14 +104,12 @@ template class GValueMap { return return_value; } - template T lookup(const ForwardKey &key) const + template const T &lookup(const ForwardKey &key) const { GMutablePointer value = values_.lookup_as(key); - const CPPType &type = *value.type(); - BLI_assert(type.is()); - T return_value; - type.copy_to_initialized(value.get(), &return_value); - return return_value; + BLI_assert(value.is_type()); + BLI_assert(value.get() != nullptr); + return *(const T *)value.get(); } template bool contains(const ForwardKey &key) const -- cgit v1.2.3