QStringList::join: micro-optimization
Don't call that->size() if we have already saved its value in a local temp. Surprisingly, this saves 56B in text size even on a -O3 GCC build, proving that the compiler does _not_ have enough context to const-fold the repeated size() evaluation. Change-Id: I2c41ddc4376f4e1534fc2f0d4789e42b984d3ba6 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
This commit is contained in:
parent
47d2d19cf6
commit
adf0db5243
@ -443,7 +443,7 @@ QString QtPrivate::QStringList_join(const QStringList *that, const QChar *sep, i
|
||||
if (totalLength == 0)
|
||||
return res;
|
||||
res.reserve(totalLength);
|
||||
for (int i = 0; i < that->size(); ++i) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (i)
|
||||
res.append(sep, seplen);
|
||||
res += that->at(i);
|
||||
|
Loading…
Reference in New Issue
Block a user