From adf0db5243c44a66639fc8f5462eb2d38e85bd9f Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 27 Mar 2014 14:50:20 +0100 Subject: [PATCH] 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 Reviewed-by: Olivier Goffart --- src/corelib/tools/qstringlist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index a7379b144c..a47af4adbd 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -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);