QArrayDataOps: improve appendIteratorRange

Handle contiguous iterators in there directly.

Change-Id: I3b6d45f993f82d0de5edbfcd75856f43a7f1263b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
bb10
Giuseppe D'Angelo 2021-10-13 01:34:26 +02:00
parent 14c5daad43
commit 507be11303
1 changed files with 14 additions and 4 deletions

View File

@ -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<It>::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;
}
}
}