QTzTimeZonePrivate: optimize container usage in init().

Iteration over node-based containers is so slow that the number of passes
should be minimized.

Replace QList with QVector. Saves ~0.2 KBytes in text size with gcc 4.9.

Change-Id: I93298b29b06e4a38a6f716d85f127e0af4385461
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
bb10
Anton Kudryavtsev 2016-01-25 16:11:27 +03:00
parent 5550e310f9
commit 520afea6b7
1 changed files with 9 additions and 2 deletions

View File

@ -627,8 +627,15 @@ void QTzTimeZonePrivate::init(const QByteArray &ianaId)
// Translate the TZ file into internal format
// Translate the array index based tz_abbrind into list index
m_abbreviations = abbrevMap.values();
QList<int> abbrindList = abbrevMap.keys();
const int size = abbrevMap.size();
m_abbreviations.clear();
m_abbreviations.reserve(size);
QVector<int> abbrindList;
abbrindList.reserve(size);
for (auto it = abbrevMap.cbegin(), end = abbrevMap.cend(); it != end; ++it) {
m_abbreviations.append(it.value());
abbrindList.append(it.key());
}
for (int i = 0; i < typeList.size(); ++i)
typeList[i].tz_abbrind = abbrindList.indexOf(typeList.at(i).tz_abbrind);