summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-10-13 01:34:26 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2021-10-13 19:34:36 +0200
commit507be11303c8dd9709d903f8e5ec197be66209ce (patch)
tree03121f85cbcd4d708e8faef53c693bb800360272
parent14c5daad4308743e56ae72da67611faffd092b81 (diff)
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>
-rw-r--r--src/corelib/tools/qarraydataops.h18
1 files 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<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;
+ }
}
}