QImage: split strings with splitRef() in convertWithPalette()

Optimize the string splitting by using splitRef(),
avoiding the creation of lots of substrings. Twice.

While touching the for loop, port to C++11 range-for.

Change-Id: Ia666896bc5b96c4b6973498cc4a9eeb24cadba6d
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
This commit is contained in:
Marc Mutz 2016-02-09 12:14:40 +01:00
parent 3ff5251740
commit 276d6cf239

View File

@ -2070,10 +2070,10 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format,
dest.setColorTable(clut);
QString textsKeys = src.text();
QStringList textKeyList = textsKeys.split(QLatin1Char('\n'), QString::SkipEmptyParts);
foreach (const QString &textKey, textKeyList) {
QStringList textKeySplitted = textKey.split(QLatin1String(": "));
dest.setText(textKeySplitted[0], textKeySplitted[1]);
const auto textKeyList = textsKeys.splitRef(QLatin1Char('\n'), QString::SkipEmptyParts);
for (const auto &textKey : textKeyList) {
const auto textKeySplitted = textKey.split(QLatin1String(": "));
dest.setText(textKeySplitted[0].toString(), textKeySplitted[1].toString());
}
int h = src.height();