summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2021-11-30 16:36:36 +0100
committerMarc Mutz <marc.mutz@qt.io>2021-12-01 15:03:34 +0100
commit147093edd9c8c1bd2a9fdda76c40f5aba378222b (patch)
tree86d80e9d41d022dfd28813cb8957c602d1df7ffb /src
parente977b55346facf9238892a81ba2b2b382e6f46be (diff)
QVarLengthArray: More Self-Encapsulate Field
Two more instances where we can use public API instead of accessing the data members directly. Amends 9d79e5f26ca58e7ddbb6367de044d05192107a4d. 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>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/tools/qvarlengtharray.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 18066a80ef..47062fc788 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -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;
}