From db0453742c7b156ce1d133d7c2c3c5959ff0c9e6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 25 Dec 2015 18:57:42 +0100 Subject: [PATCH] QTimeZone: don't iterate over QHash::keys() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... iterate over the hash directly. Prevents hash lookups and the creation of a temporary QList. Saves over 376b in text size on optimized GCC 4.9 Linux AMD64 builds. Change-Id: I7f1a22da33b94bc91bec89f62c471f8279a5d702 Reviewed-by: Sérgio Martins --- src/corelib/tools/qtimezoneprivate_tz.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index 85ed345869..4bb52a8d8a 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -983,9 +983,9 @@ QList QTzTimeZonePrivate::availableTimeZoneIds(QLocale::Country coun { // TODO AnyCountry QList result; - foreach (const QByteArray &key, tzZones->keys()) { - if (tzZones->value(key).country == country) - result << key; + for (auto it = tzZones->cbegin(), end = tzZones->cend(); it != end; ++it) { + if (it.value().country == country) + result << it.key(); } std::sort(result.begin(), result.end()); return result;