QTimeZonePrivate: avoid unnecessary allocations

... by replacing QString::split() with QString::splitRef()
and using the new overloaded functions:
- QLocalePrivate::languageToCode(QStringRef)
- QLocalePrivate::languageToCode(const QChar*, int)

Change-Id: I2884bdc6d3e27963ce121d659a5e092b10b4ef8c
Reviewed-by: Edward Welbourne <edward.welbourne@theqtcompany.com>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Anton Kudryavtsev 2016-03-30 18:35:23 +03:00
parent 3200653546
commit f8192405ef
2 changed files with 2 additions and 2 deletions

View File

@ -84,7 +84,7 @@ static QTzTimeZoneHash loadTzTimeZones()
// Comment lines are prefixed with a #
if (!line.isEmpty() && line.at(0) != '#') {
// Data rows are tab-separated columns Region, Coordinates, ID, Optional Comments
const QStringList parts = line.split('\t');
const auto parts = line.splitRef(QLatin1Char('\t'));
QTzTimeZone zone;
zone.country = QLocalePrivate::codeToCountry(parts.at(0));
if (parts.size() > 3)

View File

@ -391,7 +391,7 @@ static QLocale::Country userCountry()
const GEOID id = GetUserGeoID(GEOCLASS_NATION);
wchar_t code[3];
const int size = GetGeoInfo(id, GEO_ISO2, code, 3, 0);
return (size == 3) ? QLocalePrivate::codeToCountry(QString::fromWCharArray(code))
return (size == 3) ? QLocalePrivate::codeToCountry(reinterpret_cast<const QChar*>(code), size)
: QLocale::AnyCountry;
#endif // Q_OS_WINCE
}