Commit: fa50edc999c1ef2aa76e5c3a74fd5d8789fcb8bf
Author: Jacques Lucke
Date:   Thu Apr 1 12:25:30 2021 +0200
Branches: master
https://developer.blender.org/rBfa50edc999c1ef2aa76e5c3a74fd5d8789fcb8bf

BLI: return early when copying empty array

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

M       source/blender/blenlib/BLI_linear_allocator.hh

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

diff --git a/source/blender/blenlib/BLI_linear_allocator.hh 
b/source/blender/blenlib/BLI_linear_allocator.hh
index 47705b1d40b..6aa97d5c5e7 100644
--- a/source/blender/blenlib/BLI_linear_allocator.hh
+++ b/source/blender/blenlib/BLI_linear_allocator.hh
@@ -133,6 +133,9 @@ template<typename Allocator = GuardedAllocator> class 
LinearAllocator : NonCopya
    */
   template<typename T> MutableSpan<T> construct_array_copy(Span<T> src)
   {
+    if (src.is_empty()) {
+      return {};
+    }
     MutableSpan<T> dst = this->allocate_array<T>(src.size());
     uninitialized_copy_n(src.data(), src.size(), dst.data());
     return dst;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to