diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-02-11 15:05:39 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-02-12 19:42:24 +0000 |
commit | 1d38ecf54246b8109fb38f9d4679a72be8ac9a26 (patch) | |
tree | 151cfe33f393ccea8631bd5d79305bb15abc981d /src/corelib/codecs/qicucodec.cpp | |
parent | 1c0f24767136e19363f3bf0e7427e4153b542892 (diff) |
QTextCodec: micro-optimize loops.
Don't use index-based iteration, but use iterators.
Change-Id: If8dabd56ff880191bb53861e31bfa6a007802c9c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/codecs/qicucodec.cpp')
-rw-r--r-- | src/corelib/codecs/qicucodec.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp index 401384dabf..96d62f7084 100644 --- a/src/corelib/codecs/qicucodec.cpp +++ b/src/corelib/codecs/qicucodec.cpp @@ -47,6 +47,9 @@ QT_BEGIN_NAMESPACE +typedef QList<QTextCodec*>::ConstIterator TextCodecListConstIt; +typedef QList<QByteArray>::ConstIterator ByteArrayListConstIt; + static void qIcuCodecStateFree(QTextCodec::ConverterState *state) { ucnv_close(static_cast<UConverter *>(state->d)); @@ -487,20 +490,21 @@ QTextCodec *QIcuCodec::codecForNameUnlocked(const char *name) return codec; } - for (int i = 0; i < globalData->allCodecs.size(); ++i) { - QTextCodec *cursor = globalData->allCodecs.at(i); + for (TextCodecListConstIt it = globalData->allCodecs.constBegin(), cend = globalData->allCodecs.constEnd(); it != cend; ++it) { + QTextCodec *cursor = *it; if (qTextCodecNameMatch(cursor->name(), standardName)) { if (cache) cache->insert(standardName, cursor); return cursor; } QList<QByteArray> aliases = cursor->aliases(); - for (int y = 0; y < aliases.size(); ++y) - if (qTextCodecNameMatch(aliases.at(y), standardName)) { + for (ByteArrayListConstIt ait = aliases.constBegin(), acend = aliases.constEnd(); ait != acend; ++ait) { + if (qTextCodecNameMatch(*ait, standardName)) { if (cache) cache->insert(standardName, cursor); return cursor; } + } } QTextCodec *c = loadQtCodec(standardName); |