diff options
author | Jacques Lucke <jacques@blender.org> | 2021-10-03 15:49:15 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-10-03 15:49:15 +0300 |
commit | 8fc97a871fa34a0413093bb12c2825e963482a45 (patch) | |
tree | 07ff16a69392a10324857a547dde9e65d8db6694 /source/blender/blenkernel/BKE_attribute_access.hh | |
parent | 5d5a753d96350df46bf060628935e5e9e9f0c5a7 (diff) |
Cleanup: make typed output attribute movable
This comes at a small performance cost due to an additional
memory allocation, but that is not significant currently.
Diffstat (limited to 'source/blender/blenkernel/BKE_attribute_access.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_attribute_access.hh | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_attribute_access.hh b/source/blender/blenkernel/BKE_attribute_access.hh index 3e9dfda7166..25ee4d3c132 100644 --- a/source/blender/blenkernel/BKE_attribute_access.hh +++ b/source/blender/blenkernel/BKE_attribute_access.hh @@ -244,18 +244,21 @@ class OutputAttribute { template<typename T> class OutputAttribute_Typed { private: OutputAttribute attribute_; - std::optional<fn::GVMutableArray_Typed<T>> optional_varray_; + std::unique_ptr<fn::GVMutableArray_Typed<T>> optional_varray_; VMutableArray<T> *varray_ = nullptr; public: OutputAttribute_Typed(OutputAttribute attribute) : attribute_(std::move(attribute)) { if (attribute_) { - optional_varray_.emplace(attribute_.varray()); + optional_varray_ = std::make_unique<fn::GVMutableArray_Typed<T>>(attribute_.varray()); varray_ = &**optional_varray_; } } + OutputAttribute_Typed(OutputAttribute_Typed &&other) = default; + ~OutputAttribute_Typed() = default; + operator bool() const { return varray_ != nullptr; |