[Bf-blender-cvs] [afcb41a0aaa] master: BLI: simplify copy constructor of Array

Jacques Lucke noreply at git.blender.org
Tue Jul 7 20:32:47 CEST 2020


Commit: afcb41a0aaafce5b99891487a402d78a337f3809
Author: Jacques Lucke
Date:   Tue Jul 7 20:32:40 2020 +0200
Branches: master
https://developer.blender.org/rBafcb41a0aaafce5b99891487a402d78a337f3809

BLI: simplify copy constructor of Array

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

M	source/blender/blenlib/BLI_array.hh

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

diff --git a/source/blender/blenlib/BLI_array.hh b/source/blender/blenlib/BLI_array.hh
index 9732f43a268..18f9aad1000 100644
--- a/source/blender/blenlib/BLI_array.hh
+++ b/source/blender/blenlib/BLI_array.hh
@@ -89,7 +89,7 @@ class Array {
   /**
    * Create a new array that contains copies of all values.
    */
-  Array(Span<T> values)
+  Array(Span<T> values, Allocator allocator = {}) : allocator_(allocator)
   {
     size_ = values.size();
     data_ = this->get_buffer_for_size(values.size());
@@ -147,12 +147,8 @@ class Array {
     data_ = this->get_buffer_for_size(size);
   }
 
-  Array(const Array &other) : allocator_(other.allocator_)
+  Array(const Array &other) : Array(other.as_span(), other.allocator_)
   {
-    size_ = other.size();
-
-    data_ = this->get_buffer_for_size(other.size());
-    uninitialized_copy_n(other.data(), size_, data_);
   }
 
   Array(Array &&other) noexcept : allocator_(other.allocator_)



More information about the Bf-blender-cvs mailing list