diff --git a/src/corelib/text/qstringbuilder.h b/src/corelib/text/qstringbuilder.h index 17160c65b61..258ab2f4572 100644 --- a/src/corelib/text/qstringbuilder.h +++ b/src/corelib/text/qstringbuilder.h @@ -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(s.data_ptr().data()); + const auto start = d; + QConcatenable>::appendTo(*this, d); if constexpr (QConcatenable>::ExactSize) { - QConcatenable>::appendTo(*this, d); - return s; - } - - typename T::const_iterator const start = d; - QConcatenable>::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); + 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; }