path: root/src/corelib/tools/qtimezoneprivate_icu.cpp
diff options
authorMarc Mutz <>2017-01-30 15:25:23 +0100
committerMarc Mutz <>2017-03-26 06:44:29 +0000
commit59928d23fc22d916dea32f02d810b8b24b74922d (patch)
tree5b1bc9c5e3cdb713e8cd716df8189bb3afd361c6 /src/corelib/tools/qtimezoneprivate_icu.cpp
parent610a9e8f319eafcbcf193e4b90119a6f89d0caf9 (diff)
Port QLocalePrivate::*ToCode() to QLatin1String
The returned data is in US-ASCII (or else Latin-1), and resides in consecutive memory. We can therefore return it in a QLatin1String, which, however, will in general not be NUL-terminated. Many users use the return value as part of a QStringBuilder expression, and those which are not are not pessimized further by this change. The caller in qtimezoneprivate_icu looks as if it could simply zero -terminate the return value and use it as-is, as opposed to converting to UTF-8, but I left the code equivalent to the original just the same. Change-Id: I0e628af8c1320fcff8d0aacf160e859681d2b85a Reviewed-by: Edward Welbourne <> Reviewed-by: Thiago Macieira <>
Diffstat (limited to 'src/corelib/tools/qtimezoneprivate_icu.cpp')
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/tools/qtimezoneprivate_icu.cpp b/src/corelib/tools/qtimezoneprivate_icu.cpp
index 887486f567..a07b2593b9 100644
--- a/src/corelib/tools/qtimezoneprivate_icu.cpp
+++ b/src/corelib/tools/qtimezoneprivate_icu.cpp
@@ -477,9 +477,10 @@ QList<QByteArray> QIcuTimeZonePrivate::availableTimeZoneIds() const
QList<QByteArray> QIcuTimeZonePrivate::availableTimeZoneIds(QLocale::Country country) const
- QByteArray regionCode = QLocalePrivate::countryToCode(country).toUtf8();
+ const QLatin1String regionCode = QLocalePrivate::countryToCode(country);
+ const QByteArray regionCodeUtf8 = QString(regionCode).toUtf8();
UErrorCode status = U_ZERO_ERROR;
- UEnumeration *uenum = ucal_openCountryTimeZones(regionCode, &status);
+ UEnumeration *uenum = ucal_openCountryTimeZones(, &status);
QList<QByteArray> result;
if (U_SUCCESS(status))
result = uenumToIdList(uenum);