QVarLengthArray: More Self-Encapsulate Field

Two more instances where we can use public API instead of accessing the data members directly.

Amends 9d79e5f26c.

Task-number: QTBUG-84785
Change-Id: I2037339383836b0d292b3362fe1d6b056638e81a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
bb10
Marc Mutz 2021-11-30 16:36:36 +01:00
parent e977b55346
commit 147093edd9
1 changed files with 5 additions and 3 deletions

View File

@ -140,7 +140,7 @@ public:
ptr = std::exchange(other.ptr, otherInlineStorage);
} else {
// inline storage: move into our storage (doesn't matter whether inline or external)
QtPrivate::q_uninitialized_relocate_n(other.ptr, other.s, data());
QtPrivate::q_uninitialized_relocate_n(other.data(), other.size(), data());
}
s = std::exchange(other.s, 0);
return *this;
@ -550,8 +550,10 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::reallocate(qsizetype asi
if (QTypeInfo<T>::isComplex) {
// call default constructor for new objects (which can throw)
while (s < asize)
new (ptr+(s++)) T;
while (size() < asize) {
new (data() + size()) T;
++s;
}
} else {
s = asize;
}