From f8192405ef9f819f0732d65a2b047c8dd5cfabb6 Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Wed, 30 Mar 2016 18:35:23 +0300 Subject: [PATCH] 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 Reviewed-by: Marc Mutz --- src/corelib/tools/qtimezoneprivate_tz.cpp | 2 +- src/corelib/tools/qtimezoneprivate_win.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qtimezoneprivate_tz.cpp b/src/corelib/tools/qtimezoneprivate_tz.cpp index 3fcc8833e8..8040365581 100644 --- a/src/corelib/tools/qtimezoneprivate_tz.cpp +++ b/src/corelib/tools/qtimezoneprivate_tz.cpp @@ -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) diff --git a/src/corelib/tools/qtimezoneprivate_win.cpp b/src/corelib/tools/qtimezoneprivate_win.cpp index f84b66fa99..8e32db48de 100644 --- a/src/corelib/tools/qtimezoneprivate_win.cpp +++ b/src/corelib/tools/qtimezoneprivate_win.cpp @@ -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(code), size) : QLocale::AnyCountry; #endif // Q_OS_WINCE }