[Bf-blender-cvs] [739056418ef] temp-cpp-type-cleanup: simplify fill assign/construct

Jacques Lucke noreply at git.blender.org
Sun Jun 27 17:07:05 CEST 2021


Commit: 739056418ef344de03cd2e866f13ee21062c872b
Author: Jacques Lucke
Date:   Sun Jun 27 15:30:23 2021 +0200
Branches: temp-cpp-type-cleanup
https://developer.blender.org/rB739056418ef344de03cd2e866f13ee21062c872b

simplify fill assign/construct

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

M	source/blender/functions/FN_cpp_type.hh
M	source/blender/functions/FN_cpp_type_make.hh
M	source/blender/functions/intern/generic_virtual_array.cc
M	source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
M	source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc

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

diff --git a/source/blender/functions/FN_cpp_type.hh b/source/blender/functions/FN_cpp_type.hh
index 60b51266138..dd772671a1e 100644
--- a/source/blender/functions/FN_cpp_type.hh
+++ b/source/blender/functions/FN_cpp_type.hh
@@ -104,10 +104,8 @@ struct CPPTypeMembers {
   void (*relocate_construct)(void *src, void *dst) = nullptr;
   void (*relocate_construct_indices)(void *src, void *dst, IndexMask mask) = nullptr;
 
-  void (*fill_assign)(const void *value, void *dst, int64_t n) = nullptr;
   void (*fill_assign_indices)(const void *value, void *dst, IndexMask mask) = nullptr;
 
-  void (*fill_construct)(const void *value, void *dst, int64_t n) = nullptr;
   void (*fill_construct_indices)(const void *value, void *dst, IndexMask mask) = nullptr;
 
   void (*debug_print)(const void *value, std::stringstream &ss) = nullptr;
@@ -496,12 +494,9 @@ class CPPType : NonCopyable, NonMovable {
    *
    * Other instances of the same type should live in the array before this method is called.
    */
-  void fill_assign(const void *value, void *dst, int64_t n) const
+  void fill_assign_n(const void *value, void *dst, int64_t n) const
   {
-    BLI_assert(n == 0 || this->pointer_can_point_to_instance(value));
-    BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst));
-
-    m_.fill_assign(value, dst, n);
+    this->fill_assign_indices(value, dst, IndexMask(n));
   }
 
   void fill_assign_indices(const void *value, void *dst, IndexMask mask) const
@@ -517,12 +512,9 @@ class CPPType : NonCopyable, NonMovable {
    *
    * The array should be uninitialized before this method is called.
    */
-  void fill_construct(const void *value, void *dst, int64_t n) const
+  void fill_construct_n(const void *value, void *dst, int64_t n) const
   {
-    BLI_assert(n == 0 || this->pointer_can_point_to_instance(value));
-    BLI_assert(n == 0 || this->pointer_can_point_to_instance(dst));
-
-    m_.fill_construct(value, dst, n);
+    this->fill_construct_indices(value, dst, IndexMask(n));
   }
 
   void fill_construct_indices(const void *value, void *dst, IndexMask mask) const
diff --git a/source/blender/functions/FN_cpp_type_make.hh b/source/blender/functions/FN_cpp_type_make.hh
index 8a12b32b805..8760c49ffe2 100644
--- a/source/blender/functions/FN_cpp_type_make.hh
+++ b/source/blender/functions/FN_cpp_type_make.hh
@@ -233,11 +233,9 @@ template<typename T> inline std::unique_ptr<const CPPType> create_cpp_type(Strin
     }
   }
   if constexpr (std::is_copy_assignable_v<T>) {
-    m.fill_assign = fill_assign_cb<T>;
     m.fill_assign_indices = fill_assign_indices_cb<T>;
   }
   if constexpr (std::is_copy_constructible_v<T>) {
-    m.fill_construct = fill_construct_cb<T>;
     m.fill_construct_indices = fill_construct_indices_cb<T>;
   }
   m.debug_print = debug_print_cb<T>;
diff --git a/source/blender/functions/intern/generic_virtual_array.cc b/source/blender/functions/intern/generic_virtual_array.cc
index b25daf40568..bd033a429de 100644
--- a/source/blender/functions/intern/generic_virtual_array.cc
+++ b/source/blender/functions/intern/generic_virtual_array.cc
@@ -182,7 +182,7 @@ void GVMutableArray::fill(const void *value)
 {
   if (this->is_span()) {
     const GMutableSpan span = this->get_internal_span();
-    type_->fill_assign(value, span.data(), size_);
+    type_->fill_assign_n(value, span.data(), size_);
   }
   else {
     for (int64_t i : IndexRange(size_)) {
diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
index 1e1533e48cf..e37822bd262 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc
@@ -298,7 +298,7 @@ static void copy_spline_domain_attributes(const CurveComponent &curve_component,
       if (size != 0) {
         BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
         spline_attribute->get(i, buffer);
-        type.fill_assign(buffer, result[offset], size);
+        type.fill_assign_n(buffer, result[offset], size);
       }
     }
 
diff --git a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
index 2f6d3ef0d6c..730cf08feaa 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_join_geometry.cc
@@ -353,7 +353,7 @@ static void ensure_control_point_attribute(const StringRef name,
 
         BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
         current_curve_attribute->get(spline_index_in_component, buffer);
-        type.fill_assign(buffer, new_attribute->data(), new_attribute->size());
+        type.fill_assign_n(buffer, new_attribute->data(), new_attribute->size());
       }
     }



More information about the Bf-blender-cvs mailing list