Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-02-18 14:40:27 +0300
committerJacques Lucke <jacques@blender.org>2021-02-18 14:40:27 +0300
commit0fe5be352558c487e24724fca4c2cb9f53a724e6 (patch)
tree099c4bbf9f4da84f53799266f5e5f87f92d1265e /source/blender/functions
parente1fe1fcc79377645cca1286c80f3aeee5b736388 (diff)
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.
Diffstat (limited to 'source/blender/functions')
-rw-r--r--source/blender/functions/FN_generic_value_map.hh10
1 files changed, 4 insertions, 6 deletions
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<typename Key> class GValueMap {
return return_value;
}
- template<typename T, typename ForwardKey> T lookup(const ForwardKey &key) const
+ template<typename T, typename ForwardKey> const T &lookup(const ForwardKey &key) const
{
GMutablePointer value = values_.lookup_as(key);
- const CPPType &type = *value.type();
- BLI_assert(type.is<T>());
- T return_value;
- type.copy_to_initialized(value.get(), &return_value);
- return return_value;
+ BLI_assert(value.is_type<T>());
+ BLI_assert(value.get() != nullptr);
+ return *(const T *)value.get();
}
template<typename ForwardKey> bool contains(const ForwardKey &key) const