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>2022-04-07 19:48:14 +0300
committerJacques Lucke <jacques@blender.org>2022-04-07 19:48:29 +0300
commit67c42e7f034aad2564d8cde1a9901d9629527daa (patch)
treea300c9d16d0a2dd0160e31985c1d803cb53ca593 /source/blender/blenkernel/intern/type_conversions.cc
parent8f344b530a6ed8530ceb780110006af68430c9d5 (diff)
Functions: optimize simple generated multi-functions
This implements two optimizations: * Reduce virtual function call overhead when a non-standard virtual array is used as input. * Use a lambda in `type_conversion.cc`. In my test setup, which creates a float attribute filled with the index, the running time drops from `4.0 ms` to `2.0 ms`. Differential Revision: https://developer.blender.org/D14585
Diffstat (limited to 'source/blender/blenkernel/intern/type_conversions.cc')
-rw-r--r--source/blender/blenkernel/intern/type_conversions.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/type_conversions.cc b/source/blender/blenkernel/intern/type_conversions.cc
index d10979eeee9..aa79199d668 100644
--- a/source/blender/blenkernel/intern/type_conversions.cc
+++ b/source/blender/blenkernel/intern/type_conversions.cc
@@ -18,7 +18,11 @@ static void add_implicit_conversion(DataTypeConversions &conversions)
static const CPPType &to_type = CPPType::get<To>();
static const std::string conversion_name = from_type.name() + " to " + to_type.name();
- static fn::CustomMF_SI_SO<From, To> multi_function{conversion_name.c_str(), ConversionF};
+ static fn::CustomMF_SI_SO<From, To> multi_function{
+ conversion_name.c_str(),
+ /* Use lambda instead of passing #ConversionF directly, because otherwise the compiler won't
+ inline the function. */
+ [](const From &a) { return ConversionF(a); }};
static auto convert_single_to_initialized = [](const void *src, void *dst) {
*(To *)dst = ConversionF(*(const From *)src);
};