diff options
Diffstat (limited to 'src/corelib/text/qstringbuilder.h')
-rw-r--r-- | src/corelib/text/qstringbuilder.h | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/corelib/text/qstringbuilder.h b/src/corelib/text/qstringbuilder.h index dfe9863b74..853033b2d9 100644 --- a/src/corelib/text/qstringbuilder.h +++ b/src/corelib/text/qstringbuilder.h @@ -101,7 +101,7 @@ private: return T(); } - const qsizetype len = QConcatenable< QStringBuilder<A, B> >::size(*this); + const qsizetype len = Concatenable::size(*this); T s(len, Qt::Uninitialized); // Using data_ptr() here (private API) so we can bypass the @@ -109,18 +109,17 @@ private: // both QString and QByteArray's data() and constData(). The result is // the same if len != 0. auto d = reinterpret_cast<typename T::iterator>(s.data_ptr().data()); - - if constexpr (QConcatenable<QStringBuilder<A, B>>::ExactSize) { - QConcatenable<QStringBuilder<A, B>>::appendTo(*this, d); - return s; - } - - typename T::const_iterator const start = d; - QConcatenable<QStringBuilder<A, B>>::appendTo(*this, d); - if (len != d - start) { - // this resize is necessary since we allocate a bit too much - // when dealing with variable sized 8-bit encodings - s.resize(d - start); + const auto start = d; + Concatenable::appendTo(*this, d); + + if constexpr (Concatenable::ExactSize) { + Q_UNUSED(start) + } else { + if (len != d - start) { + // this resize is necessary since we allocate a bit too much + // when dealing with variable sized 8-bit encodings + s.resize(d - start); + } } return s; } |