[Bf-blender-cvs] [8fc97a871fa] master: Cleanup: make typed output attribute movable

Jacques Lucke noreply at git.blender.org
Sun Oct 3 15:01:11 CEST 2021


Commit: 8fc97a871fa34a0413093bb12c2825e963482a45
Author: Jacques Lucke
Date:   Sun Oct 3 14:49:15 2021 +0200
Branches: master
https://developer.blender.org/rB8fc97a871fa34a0413093bb12c2825e963482a45

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.

===================================================================

M	source/blender/blenkernel/BKE_attribute_access.hh

===================================================================

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;



More information about the Bf-blender-cvs mailing list