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:
authorHans Goudey <h.goudey@me.com>2022-08-02 21:44:07 +0300
committerHans Goudey <h.goudey@me.com>2022-08-02 21:44:07 +0300
commita48e5c53a546cd5e493a9e816ce9ed71f0e61a8b (patch)
treeba39edf9a1dd2d774c82df9c373083c13ef26dba /source/blender/blenlib/BLI_virtual_array.hh
parent2ba2efc29691762d3fb2002f54adafd536b2c37b (diff)
Cleanup: Simplify const cast in virtual array construction
Diffstat (limited to 'source/blender/blenlib/BLI_virtual_array.hh')
-rw-r--r--source/blender/blenlib/BLI_virtual_array.hh11
1 files changed, 7 insertions, 4 deletions
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<typename T> class VArrayImpl_For_Span_final final : public VArrayImpl_F
public:
using VArrayImpl_For_Span<T>::VArrayImpl_For_Span;
+ VArrayImpl_For_Span_final(const Span<T> data)
+ /* Cast const away, because the implementation for const and non const spans is shared. */
+ : VArrayImpl_For_Span<T>({const_cast<T *>(data.data()), data.size()})
+ {
+ }
+
private:
CommonVArrayInfo common_info() const final
{
@@ -898,10 +904,7 @@ template<typename T> class VArray : public VArrayCommon<T> {
VArray(varray_tag::span /* tag */, Span<T> span)
{
- /* Cast const away, because the virtual array implementation for const and non const spans is
- * shared. */
- MutableSpan<T> mutable_span{const_cast<T *>(span.data()), span.size()};
- this->template emplace<VArrayImpl_For_Span_final<T>>(mutable_span);
+ this->template emplace<VArrayImpl_For_Span_final<T>>(span);
}
VArray(varray_tag::single /* tag */, T value, const int64_t size)