summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-04-10 10:00:01 -0700
committerThiago Macieira <thiago.macieira@intel.com>2024-04-18 14:35:58 -0700
commit2e8c6d467fa245e8bcb81cff63d2d9628e1ee81e (patch)
tree1271167e0375272cd2e5e267dd1274355b2553f7 /src/corelib
parent71e87993d6bb9c3bf61883d66f97a5e0cfa2bfb1 (diff)
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 Pick-to: 6.7 Change-Id: I40526efc4e93413794c3fffd17c4f9c96ee187f9 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/text/qstringbuilder.h19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/corelib/text/qstringbuilder.h b/src/corelib/text/qstringbuilder.h
index dfe9863b74..52dbd52b47 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<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;
}