Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-04-01 13:25:30 +0300
committerJacques Lucke <jacques@blender.org>2021-04-01 13:38:14 +0300
commitfa50edc999c1ef2aa76e5c3a74fd5d8789fcb8bf (patch)
treea673b05f45cdcd5682bd3acf2786e333d2c9f3b0 /source/blender/blenlib/BLI_linear_allocator.hh
parent0ffbcc44168dc3b2058a16648775c874dce89727 (diff)
BLI: return early when copying empty array
Diffstat (limited to 'source/blender/blenlib/BLI_linear_allocator.hh')
-rw-r--r--source/blender/blenlib/BLI_linear_allocator.hh3
1 files changed, 3 insertions, 0 deletions
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;