From a48e5c53a546cd5e493a9e816ce9ed71f0e61a8b Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 2 Aug 2022 13:44:07 -0500 Subject: Cleanup: Simplify const cast in virtual array construction --- source/blender/blenlib/BLI_virtual_array.hh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source/blender/blenlib/BLI_virtual_array.hh') diff --git a/source/blender/blenlib/BLI_virtual_array.hh b/source/blender/blenlib/BLI_virtual_array.hh index 438fcc4b8f7..7eab960b302 100644 --- a/source/blender/blenlib/BLI_virtual_array.hh +++ b/source/blender/blenlib/BLI_virtual_array.hh @@ -315,6 +315,12 @@ template class VArrayImpl_For_Span_final final : public VArrayImpl_F public: using VArrayImpl_For_Span::VArrayImpl_For_Span; + VArrayImpl_For_Span_final(const Span data) + /* Cast const away, because the implementation for const and non const spans is shared. */ + : VArrayImpl_For_Span({const_cast(data.data()), data.size()}) + { + } + private: CommonVArrayInfo common_info() const final { @@ -898,10 +904,7 @@ template class VArray : public VArrayCommon { VArray(varray_tag::span /* tag */, Span span) { - /* Cast const away, because the virtual array implementation for const and non const spans is - * shared. */ - MutableSpan mutable_span{const_cast(span.data()), span.size()}; - this->template emplace>(mutable_span); + this->template emplace>(span); } VArray(varray_tag::single /* tag */, T value, const int64_t size) -- cgit v1.2.3