[Bf-blender-cvs] [a3dfcd003a7] virtual-array-attributes: cleanup

Jacques Lucke noreply at git.blender.org
Mon Apr 12 18:27:55 CEST 2021


Commit: a3dfcd003a70a264b38525052bb5c66c2f9b2378
Author: Jacques Lucke
Date:   Sat Apr 10 18:55:07 2021 +0200
Branches: virtual-array-attributes
https://developer.blender.org/rBa3dfcd003a70a264b38525052bb5c66c2f9b2378

cleanup

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

M	source/blender/blenlib/BLI_virtual_array.hh
M	source/blender/functions/FN_generic_virtual_array.hh
M	source/blender/functions/intern/generic_virtual_array.cc

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

diff --git a/source/blender/blenlib/BLI_virtual_array.hh b/source/blender/blenlib/BLI_virtual_array.hh
index 6f7c42c9bbf..81142a0cabb 100644
--- a/source/blender/blenlib/BLI_virtual_array.hh
+++ b/source/blender/blenlib/BLI_virtual_array.hh
@@ -243,7 +243,7 @@ template<typename T> class VMutableArray : public VArray<T> {
  * devirtualized by the compiler in some cases (e.g. when #devirtualize_varray is used).
  */
 template<typename T> class VArray_For_Span : public VArray<T> {
- private:
+ protected:
   const T *data_ = nullptr;
 
  public:
@@ -251,16 +251,9 @@ template<typename T> class VArray_For_Span : public VArray<T> {
   {
   }
 
-  /* When this constructor is used, the #set_span_start method has to be used as well. */
-  VArray_For_Span(const int64_t size) : VArray<T>(size)
-  {
-  }
-
  protected:
-  /* Can be used when the data pointer is not ready when the constructor is called. */
-  void set_span_start(const T *data)
+  VArray_For_Span(const int64_t size) : VArray<T>(size)
   {
-    data_ = data;
   }
 
   T get_impl(const int64_t index) const final
@@ -280,7 +273,7 @@ template<typename T> class VArray_For_Span : public VArray<T> {
 };
 
 template<typename T> class VMutableArray_For_MutableSpan final : public VMutableArray<T> {
- private:
+ protected:
   T *data_ = nullptr;
 
  public:
@@ -289,16 +282,9 @@ template<typename T> class VMutableArray_For_MutableSpan final : public VMutable
   {
   }
 
-  /* When this constructor is used, the #set_span_start method has to be used as well. */
-  VMutableArray_For_MutableSpan(const int64_t size) : VMutableArray<T>(size)
-  {
-  }
-
  protected:
-  /* Can be used when the data pointer is not ready when the constructor is called. */
-  void set_span_start(T *data)
+  VMutableArray_For_MutableSpan(const int64_t size) : VMutableArray<T>(size)
   {
-    data_ = data;
   }
 
   T get_impl(const int64_t index) const override
@@ -337,7 +323,7 @@ class VArray_For_ArrayContainer : public VArray_For_Span<T> {
   VArray_For_ArrayContainer(Container container)
       : VArray_For_Span<T>((int64_t)container.size()), container_(std::move(container))
   {
-    this->set_span_start(container_.data());
+    this->data_ = container_.data();
   }
 };
 
@@ -402,13 +388,13 @@ template<typename T> class VArray_As_Span final : public VArray_For_Span<T> {
   VArray_As_Span(const VArray<T> &varray) : VArray_For_Span<T>(varray.size()), varray_(varray)
   {
     if (varray_.is_span()) {
-      this->set_span_start(varray_.get_span().data());
+      this->data_ = varray_.get_span().data();
     }
     else {
       owned_data_.~Array();
       new (&owned_data_) Array<T>(varray_.size(), NoInitialization{});
       varray_.materialize_to_uninitialized(owned_data_);
-      this->set_span_start(owned_data_.data());
+      this->data_ = owned_data_.data();
     }
   }
 
@@ -436,13 +422,13 @@ class VMutableArray_As_MutableSpan final : public VMutableArray_For_MutableSpan<
       : VMutableArray_For_MutableSpan<T>(varray.size())
   {
     if (varray_.is_span()) {
-      this->set_span_start(varray_.get_span().data());
+      this->data_ = varray_.get_span().data();
     }
     else {
       owned_data_.~Array();
       new (&owned_data_) Array<T>(varray_.size(), NoInitialization{});
       varray_.materialize_to_uninitialized(owned_data_);
-      this->set_span_start(owned_data_.data());
+      this->data_ = owned_data_.data();
     }
   }
 
diff --git a/source/blender/functions/FN_generic_virtual_array.hh b/source/blender/functions/FN_generic_virtual_array.hh
index 0a46da505e7..30ed8dde1c7 100644
--- a/source/blender/functions/FN_generic_virtual_array.hh
+++ b/source/blender/functions/FN_generic_virtual_array.hh
@@ -199,18 +199,12 @@ class GVArray_For_GSpan : public GVArray {
   {
   }
 
-  /* When this constructor is used, the #set_span_start method should be used as well. */
+ protected:
   GVArray_For_GSpan(const CPPType &type, const int64_t size)
       : GVArray(type, size), element_size_(type.size())
   {
   }
 
- protected:
-  void set_span_start(const void *data)
-  {
-    data_ = data;
-  }
-
   void get_impl(const int64_t index, void *r_value) const override;
   void get_to_uninitialized_impl(const int64_t index, void *r_value) const override;
 
@@ -244,18 +238,12 @@ class GVMutableArray_For_GMutableSpan : public GVMutableArray {
   {
   }
 
-  /* When this constructor is used, the #set_span_start method has to be used as well. */
+ protected:
   GVMutableArray_For_GMutableSpan(const CPPType &type, const int64_t size)
       : GVMutableArray(type, size), element_size_(type.size())
   {
   }
 
- protected:
-  void set_span_start(void *data)
-  {
-    data_ = data;
-  }
-
   void get_impl(const int64_t index, void *r_value) const override;
   void get_to_uninitialized_impl(const int64_t index, void *r_value) const override;
 
diff --git a/source/blender/functions/intern/generic_virtual_array.cc b/source/blender/functions/intern/generic_virtual_array.cc
index 92861de870c..a8dcd21b1dc 100644
--- a/source/blender/functions/intern/generic_virtual_array.cc
+++ b/source/blender/functions/intern/generic_virtual_array.cc
@@ -183,12 +183,12 @@ GVArray_As_GSpan::GVArray_As_GSpan(const GVArray &varray)
     : GVArray_For_GSpan(varray.type(), varray.size()), varray_(varray)
 {
   if (varray_.is_span()) {
-    this->set_span_start(varray_.get_span().data());
+    data_ = varray_.get_span().data();
   }
   else {
     owned_data_ = MEM_mallocN_aligned(type_->size() * size_, type_->alignment(), __func__);
     varray_.materialize_to_uninitialized(IndexRange(size_), owned_data_);
-    this->set_span_start(owned_data_);
+    data_ = owned_data_;
   }
 }
 
@@ -218,12 +218,12 @@ GVMutableArray_As_GMutableSpan::GVMutableArray_As_GMutableSpan(GVMutableArray &v
     : GVMutableArray_For_GMutableSpan(varray.type(), varray.size()), varray_(varray)
 {
   if (varray_.is_span()) {
-    this->set_span_start(varray_.get_span().data());
+    data_ = varray_.get_span().data();
   }
   else {
     owned_data_ = MEM_mallocN_aligned(type_->size() * size_, type_->alignment(), __func__);
     varray_.materialize_to_uninitialized(IndexRange(size_), owned_data_);
-    this->set_span_start(owned_data_);
+    data_ = owned_data_;
   }
 }



More information about the Bf-blender-cvs mailing list