summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qarraydataops.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-11-10 11:30:04 +0100
committerLars Knoll <lars.knoll@qt.io>2020-11-17 11:46:57 +0100
commitf1db4d6e385deae976b6bf9b3cd392b794e09383 (patch)
tree1f3e61e31435b5fe6ead0afd775311e0352791f3 /src/corelib/tools/qarraydataops.h
parent07c7cbf1a0b491125cf91570a870725b35e4cb71 (diff)
Fix moveAppend() implementation
When appending multiple items, we are fine with providing weak exception safety only. This implies that we can simplify the moveAppend() code and avoid having to potentiall call destructors in there. Change-Id: I31cef0e8589e28f3d3521c54db3f7910628e686f Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qarraydataops.h')
-rw-r--r--src/corelib/tools/qarraydataops.h22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h
index e0f3484bcb..9e5057099e 100644
--- a/src/corelib/tools/qarraydataops.h
+++ b/src/corelib/tools/qarraydataops.h
@@ -113,15 +113,6 @@ struct QArrayExceptionSafetyPrimitives
}
return qsizetype(std::exchange(n, 0));
}
- qsizetype move(T *first, T *last) noexcept(std::is_nothrow_move_constructible_v<T>)
- {
- n = 0;
- for (; first != last; ++first) {
- new (where + n) T(std::move(*first));
- ++n;
- }
- return qsizetype(std::exchange(n, 0));
- }
~Constructor() noexcept(std::is_nothrow_destructible_v<T>)
{
while (n)
@@ -544,13 +535,12 @@ public:
if (b == e)
return;
- typedef typename QArrayExceptionSafetyPrimitives<T>::Constructor CopyConstructor;
-
- // Provides strong exception safety guarantee,
- // provided T::~T() nothrow
-
- CopyConstructor copier(this->end());
- this->size += copier.move(b, e);
+ T *data = this->begin();
+ while (b < e) {
+ new (data + this->size) T(std::move(*b));
+ ++b;
+ ++this->size;
+ }
}
void truncate(size_t newSize)