QStringBuilder: DRY: simplify the if constexpr conditionals a bit

Both sides of it were calling the same appendTo(), so we can avoid
repeating ourselves. This MAY fix a warning with VS2019.

Fixes: QTBUG-124117
Change-Id: I40526efc4e93413794c3fffd17c4f9c96ee187f9
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
(cherry picked from commit 2e8c6d467fa245e8bcb81cff63d2d9628e1ee81e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2024-04-10 10:00:01 -07:00 committed by Qt Cherry-pick Bot
parent 249b8ff3ff
commit 5edb9a6a0f

View File

@ -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());
const auto start = d;
QConcatenable<QStringBuilder<A, B>>::appendTo(*this, d);
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);
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;
}