[Bf-blender-cvs] [67724f884ae] functions: use new indices functions

Jacques Lucke noreply at git.blender.org
Sat Dec 14 17:54:27 CET 2019


Commit: 67724f884ae2cef2158e363fbecdf4cabd9ad2a0
Author: Jacques Lucke
Date:   Sat Dec 14 17:50:33 2019 +0100
Branches: functions
https://developer.blender.org/rB67724f884ae2cef2158e363fbecdf4cabd9ad2a0

use new indices functions

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

M	source/blender/functions/FN_generic_array_ref.h
M	source/blender/functions/FN_generic_vector_array.h

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

diff --git a/source/blender/functions/FN_generic_array_ref.h b/source/blender/functions/FN_generic_array_ref.h
index 108322727c6..d1732e3d258 100644
--- a/source/blender/functions/FN_generic_array_ref.h
+++ b/source/blender/functions/FN_generic_array_ref.h
@@ -87,22 +87,12 @@ class GenericMutableArrayRef {
 
   void destruct_all()
   {
-    if (m_type->trivially_destructible()) {
-      return;
-    }
-    for (uint i = 0; i < m_size; i++) {
-      m_type->destruct((*this)[i]);
-    }
+    m_type->destruct_n(m_buffer, m_size);
   }
 
   void destruct_indices(ArrayRef<uint> indices)
   {
-    if (m_type->trivially_destructible()) {
-      return;
-    }
-    for (uint i : indices) {
-      m_type->destruct((*this)[i]);
-    }
+    m_type->destruct_indices(m_buffer, indices);
   }
 
   GenericMutableArrayRef slice(uint start, uint size)
@@ -128,9 +118,7 @@ class GenericMutableArrayRef {
 
   void default_initialize(ArrayRef<uint> indices)
   {
-    for (uint i : indices) {
-      m_type->construct_default((*this)[i]);
-    }
+    m_type->construct_default_indices(m_buffer, indices);
   }
 
   void fill__uninitialized(const void *value)
diff --git a/source/blender/functions/FN_generic_vector_array.h b/source/blender/functions/FN_generic_vector_array.h
index f37cd1fec08..30b6543ebe8 100644
--- a/source/blender/functions/FN_generic_vector_array.h
+++ b/source/blender/functions/FN_generic_vector_array.h
@@ -105,10 +105,7 @@ class GenericVectorArray : BLI::NonCopyable, BLI::NonMovable {
 
     if (values.is_single_element()) {
       const void *value = values.as_single_element();
-      for (uint i = 0; i < extend_length; i++) {
-        void *dst = POINTER_OFFSET(start, m_element_size * i);
-        m_type.copy_to_uninitialized(value, dst);
-      }
+      m_type.fill_uninitialized(value, start, extend_length);
     }
     else if (values.is_non_single_full_array()) {
       GenericArrayRef array = values.as_full_array();
@@ -181,9 +178,7 @@ class GenericVectorArray : BLI::NonCopyable, BLI::NonMovable {
 
     void extend_single(uint index, ArrayRef<T> values)
     {
-      for (const T &value : values) {
-        this->append_single(index, value);
-      }
+      m_data->extend_single__copy(index, GenericVirtualListRef::FromFullArray(values));
     }
 
     MutableArrayRef<T> allocate_and_default_construct(uint index, uint amount)
@@ -233,10 +228,7 @@ class GenericVectorArray : BLI::NonCopyable, BLI::NonMovable {
     }
 
     for (uint index = 0; index < m_array_size; index++) {
-      for (uint i = 0; i < m_lengths[index]; i++) {
-        void *ptr = POINTER_OFFSET(m_starts[index], m_element_size * i);
-        m_type.destruct(ptr);
-      }
+      m_type.destruct_n(m_starts[index], m_lengths[index]);
     }
   }
 };



More information about the Bf-blender-cvs mailing list