From 507be11303c8dd9709d903f8e5ec197be66209ce Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 13 Oct 2021 01:34:26 +0200 Subject: [PATCH] QArrayDataOps: improve appendIteratorRange MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Handle contiguous iterators in there directly. Change-Id: I3b6d45f993f82d0de5edbfcd75856f43a7f1263b Reviewed-by: Fabian Kosmale Reviewed-by: MÃ¥rten Nordheim --- src/corelib/tools/qarraydataops.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h index 9a2f43cbb1..173e3cac2e 100644 --- a/src/corelib/tools/qarraydataops.h +++ b/src/corelib/tools/qarraydataops.h @@ -911,10 +911,20 @@ public: Q_ASSERT(distance >= 0 && distance <= this->allocatedCapacity() - this->size); Q_UNUSED(distance); - T *iter = this->end(); - for (; b != e; ++iter, ++b) { - new (iter) T(*b); - ++this->size; +#if __cplusplus >= 202002L + if constexpr ( + std::is_convertible_v< + typename std::iterator_traits::iterator_category, + std::contiguous_iterator_tag>) { + this->copyAppend(std::to_address(b), std::to_address(e)); + } else +#endif + { + T *iter = this->end(); + for (; b != e; ++iter, ++b) { + new (iter) T(*b); + ++this->size; + } } }