From 53ec85637ca55d63a765b10f2714eada57dc1ded Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 24 Jun 2015 01:49:34 +0200 Subject: QImageIOHandler: don't create QLists just to count their elements Q(Multi)Map::keys() returns duplicated keys, so keys().size() will always be the same as the map's size(). So use that directly instead of creating temporary QLists to check the size. Change-Id: I0600d1845e25be3b825e4ae470c1ef41a3a5d2c9 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/gui/image/qimagereader.cpp | 6 +++--- src/gui/image/qimagewriter.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gui/image') diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index cbe241c577..618352d363 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -252,7 +252,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, #ifdef QIMAGEREADER_DEBUG qDebug() << "QImageReader::createReadHandler( device =" << (void *)device << ", format =" << format << ")," - << keyMap.values().size() << "plugins available: " << keyMap.values(); + << keyMap.size() << "plugins available: " << keyMap.values(); #endif int suffixPluginIndex = -1; @@ -312,7 +312,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, const qint64 pos = device ? device->pos() : 0; if (autoDetectImageFormat) { - const int keyCount = keyMap.keys().size(); + const int keyCount = keyMap.size(); for (int i = 0; i < keyCount; ++i) { if (i != suffixPluginIndex) { QImageIOPlugin *plugin = qobject_cast(l->instance(i)); @@ -392,7 +392,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, if (!handler && (autoDetectImageFormat || ignoresFormatAndExtension)) { // check if any of our plugins recognize the file from its contents. const qint64 pos = device ? device->pos() : 0; - const int keyCount = keyMap.keys().size(); + const int keyCount = keyMap.size(); for (int i = 0; i < keyCount; ++i) { if (i != suffixPluginIndex) { QImageIOPlugin *plugin = qobject_cast(l->instance(i)); diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index 5c1a5c7ab1..1cf75d8688 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -212,7 +212,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, #ifndef QT_NO_IMAGEFORMATPLUGIN if (!testFormat.isEmpty()) { - const int keyCount = keyMap.keys().size(); + const int keyCount = keyMap.size(); for (int i = 0; i < keyCount; ++i) { QImageIOPlugin *plugin = qobject_cast(l->instance(i)); if (plugin && (plugin->capabilities(device, testFormat) & QImageIOPlugin::CanWrite)) { -- cgit v1.2.3