Commit: 3bcb30b13b6085c19e7173953beb899171d1e130
Author: Jacques Lucke
Date:   Sun Sep 26 13:39:27 2021 +0200
Branches: temp-varray-get-set-multiple
https://developer.blender.org/rB3bcb30b13b6085c19e7173953beb899171d1e130

cleanup

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

M       source/blender/blenlib/BLI_virtual_array.hh
M       source/blender/functions/intern/field.cc

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

diff --git a/source/blender/blenlib/BLI_virtual_array.hh 
b/source/blender/blenlib/BLI_virtual_array.hh
index 09741c0a42d..8c348625226 100644
--- a/source/blender/blenlib/BLI_virtual_array.hh
+++ b/source/blender/blenlib/BLI_virtual_array.hh
@@ -743,6 +743,10 @@ class VMutableArray_For_DerivedSpan : public 
VMutableArray<ElemT> {
       const ElemT *src_ptr = src_varray.get_internal_span().data();
       mask.foreach_index([&](const int64_t i) { SetFunc(data_[i], src_ptr[i]); 
});
     }
+    else if (src_varray.is_single()) {
+      const ElemT src_value = src_varray.get_internal_single();
+      mask.foreach_index([&](const int64_t i) { SetFunc(data_[i], src_value); 
});
+    }
     else {
       mask.foreach_index([&](const int64_t i) { SetFunc(data_[i], 
src_varray.get(i)); });
     }
@@ -750,7 +754,7 @@ class VMutableArray_For_DerivedSpan : public 
VMutableArray<ElemT> {
 
   virtual bool can_set_multiple_efficiently_impl(const VArray<ElemT> 
&src_varray) const
   {
-    return src_varray.is_span();
+    return src_varray.is_span() || src_varray.is_single();
   }
 };
 
diff --git a/source/blender/functions/intern/field.cc 
b/source/blender/functions/intern/field.cc
index 3930165b58f..c34182924cb 100644
--- a/source/blender/functions/intern/field.cc
+++ b/source/blender/functions/intern/field.cc
@@ -468,21 +468,7 @@ Vector<const GVArray *> evaluate_fields(ResourceScope 
&scope,
         /* The result has been written into the destination provided by the 
caller already. */
         continue;
       }
-      /* Still have to copy over the data in the destination provided by the 
caller. */
-      if (output_varray->is_span()) {
-        /* Materialize into a span. */
-        
computed_varray->get_multiple_to_uninitialized(output_varray->get_internal_span().data(),
-                                                       mask);
-      }
-      else {
-        /* Slower materialize into a different structure. */
-        const CPPType &type = computed_varray->type();
-        BUFFER_FOR_CPP_TYPE_VALUE(type, buffer);
-        for (const int i : mask) {
-          computed_varray->get_to_uninitialized(i, buffer);
-          output_varray->set_by_relocate(i, buffer);
-        }
-      }
+      output_varray->set_multiple_by_copy(*computed_varray, mask);
       r_varrays[out_index] = output_varray;
     }
   }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to