diff options
author | Jacques Lucke <jacques@blender.org> | 2021-11-26 11:59:41 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-11-26 11:59:41 +0300 |
commit | 2cda65a35a61e0bb74f4b2b896feede73c329b59 (patch) | |
tree | 9d9460de93f1dd021b4bc36d2c78776b2f782a9c /source/blender/functions/FN_cpp_type.hh | |
parent | 8015433f81b4956e4ee4efffb80ab10324df5675 (diff) |
Geometry Nodes: avoid allocation when construct varray for single value
Previously, `GVArray::ForSingle` would always allocate a copy of the passed
in value. Now it only does so when the value is too large or not trivial.
Diffstat (limited to 'source/blender/functions/FN_cpp_type.hh')
-rw-r--r-- | source/blender/functions/FN_cpp_type.hh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh index 643b2fc1f28..7ddb5bf1f46 100644 --- a/source/blender/functions/FN_cpp_type.hh +++ b/source/blender/functions/FN_cpp_type.hh @@ -207,6 +207,18 @@ class CPPType : NonCopyable, NonMovable { return is_trivially_destructible_; } + /** + * When true, the value is like a normal C type, it can be copied around with #memcpy and does + * not have to be destructed. + * + * C++ equivalent: + * std::is_trivial_v<T>; + */ + bool is_trivial() const + { + return is_trivial_; + } + bool is_default_constructible() const { return default_construct_ != nullptr; |