Skip to content

Commit

Permalink
QVarLengthArray: More Self-Encapsulate Field
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
marcmutz committed Dec 1, 2021
1 parent e977b55 commit 147093e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/corelib/tools/qvarlengtharray.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class QVarLengthArray
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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 147093e

Please sign in to comment.