Skip to content

Commit 147093e

Browse files
committed
QVarLengthArray: More Self-Encapsulate Field
Two more instances where we can use public API instead of accessing the data members directly. Amends 9d79e5f. Task-number: QTBUG-84785 Change-Id: I2037339383836b0d292b3362fe1d6b056638e81a Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
1 parent e977b55 commit 147093e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/corelib/tools/qvarlengtharray.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class QVarLengthArray
140140
ptr = std::exchange(other.ptr, otherInlineStorage);
141141
} else {
142142
// inline storage: move into our storage (doesn't matter whether inline or external)
143-
QtPrivate::q_uninitialized_relocate_n(other.ptr, other.s, data());
143+
QtPrivate::q_uninitialized_relocate_n(other.data(), other.size(), data());
144144
}
145145
s = std::exchange(other.s, 0);
146146
return *this;
@@ -550,8 +550,10 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::reallocate(qsizetype asi
550550

551551
if (QTypeInfo<T>::isComplex) {
552552
// call default constructor for new objects (which can throw)
553-
while (s < asize)
554-
new (ptr+(s++)) T;
553+
while (size() < asize) {
554+
new (data() + size()) T;
555+
++s;
556+
}
555557
} else {
556558
s = asize;
557559
}

0 commit comments

Comments
 (0)