diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-02-09 12:14:40 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2016-02-11 19:25:43 +0000 |
commit | 276d6cf239bdb0a39ae589e13f60b2a31a2efb60 (patch) | |
tree | fccbcfd41c67d8137106e1a2af0fc2000228c17e /src | |
parent | 3ff5251740f4c4cca74177cc977ebe7df6e7f92b (diff) |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/image/qimage.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 09c92b45a4..24838080e7 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -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(); |