diff options
-rw-r--r-- | src/corelib/text/qlocale.cpp | 12 | ||||
-rw-r--r-- | src/corelib/text/qlocale_data_p.h | 2 | ||||
-rw-r--r-- | src/corelib/text/qlocale_unix.cpp | 4 |
3 files changed, 8 insertions, 10 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 153a25a035..e19a63fe1a 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -3103,10 +3103,10 @@ Qt::DayOfWeek QLocale::firstDayOfWeek() const QLocale::MeasurementSystem QLocalePrivate::measurementSystem() const { - for (int i = 0; i < ImperialMeasurementSystemsCount; ++i) { - if (ImperialMeasurementSystems[i].languageId == m_data->m_language_id - && ImperialMeasurementSystems[i].territoryId == m_data->m_territory_id) { - return ImperialMeasurementSystems[i].system; + for (const auto &system : ImperialMeasurementSystems) { + if (system.languageId == m_data->m_language_id + && system.territoryId == m_data->m_territory_id) { + return system.system; } } return QLocale::MetricSystem; @@ -3573,8 +3573,8 @@ QString QLocaleData::doubleToString(double d, int precision, DoubleForm form, const char32_t zeroUcs4 = QChar::surrogateToUcs4(zero.at(0), zero.at(1)); QString converted; converted.reserve(2 * digits.size()); - for (int i = 0; i < digits.length(); ++i) { - const char32_t digit = unicodeForDigit(digits.at(i).unicode() - '0', zeroUcs4); + for (QChar ch : std::as_const(digits)) { + const char32_t digit = unicodeForDigit(ch.unicode() - '0', zeroUcs4); Q_ASSERT(QChar::requiresSurrogates(digit)); converted.append(QChar::highSurrogate(digit)); converted.append(QChar::lowSurrogate(digit)); diff --git a/src/corelib/text/qlocale_data_p.h b/src/corelib/text/qlocale_data_p.h index ceed2589c4..bf6e37b09f 100644 --- a/src/corelib/text/qlocale_data_p.h +++ b/src/corelib/text/qlocale_data_p.h @@ -37,8 +37,6 @@ static constexpr TerritoryLanguage ImperialMeasurementSystems[] = { { QLocale::Hawaiian, QLocale::UnitedStates, QLocale::ImperialUSSystem }, { QLocale::English, QLocale::UnitedKingdom, QLocale::ImperialUKSystem } }; -static constexpr int ImperialMeasurementSystemsCount = - sizeof(ImperialMeasurementSystems)/sizeof(ImperialMeasurementSystems[0]); /* Storage for alpha codes with length of up to 4 allowing efficient comparison. diff --git a/src/corelib/text/qlocale_unix.cpp b/src/corelib/text/qlocale_unix.cpp index c0f44fb953..6f6884d366 100644 --- a/src/corelib/text/qlocale_unix.cpp +++ b/src/corelib/text/qlocale_unix.cpp @@ -244,9 +244,9 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const else lst = languages.split(u':'); - for (int i = 0; i < lst.size(); ++i) { + for (const QString &e : std::as_const(lst)) { QStringView language, script, territory; - if (qt_splitLocaleName(lst.at(i), &language, &script, &territory)) { + if (qt_splitLocaleName(e, &language, &script, &territory)) { QString joined = language.isEmpty() ? u"und"_s : language.toString(); if (!script.isEmpty()) joined += u'-' + script; |