diff options
author | Jacques Lucke <jacques@blender.org> | 2021-04-29 13:59:44 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-04-29 13:59:44 +0300 |
commit | 4e10b196ac15339cfded8d5615f04ac40c93e19b (patch) | |
tree | a2288584d4433f1a32047adb393edb51cf863165 /source/blender/functions/intern | |
parent | f903e3a3fd003e5295f7aea35710a77b2e74f846 (diff) |
Functions: make copying virtual arrays to span more efficient
Sometimes functions expect a span instead of a virtual array.
If the virtual array is a span internally already, great. But if it is
not (e.g. the position attribute on a mesh), the elements have
to be copied over to a span.
This patch makes the copying process more efficient by giving
the compiler more opportunity for optimization.
Diffstat (limited to 'source/blender/functions/intern')
-rw-r--r-- | source/blender/functions/intern/generic_virtual_array.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/blender/functions/intern/generic_virtual_array.cc b/source/blender/functions/intern/generic_virtual_array.cc index e11501828f8..754a2156a65 100644 --- a/source/blender/functions/intern/generic_virtual_array.cc +++ b/source/blender/functions/intern/generic_virtual_array.cc @@ -22,8 +22,19 @@ namespace blender::fn { * GVArray. */ +void GVArray::materialize_to_uninitialized(void *dst) const +{ + this->materialize_to_uninitialized(IndexMask(size_), dst); +} + void GVArray::materialize_to_uninitialized(const IndexMask mask, void *dst) const { + BLI_assert(mask.min_array_size() <= size_); + this->materialize_to_uninitialized_impl(mask, dst); +} + +void GVArray::materialize_to_uninitialized_impl(const IndexMask mask, void *dst) const +{ for (const int64_t i : mask) { void *elem_dst = POINTER_OFFSET(dst, type_->size() * i); this->get_to_uninitialized(i, elem_dst); |