QLocale: port to qsizetype [1/N]: indexed to ranged loops
Ranged for loops are independent of the container's size_type, so port what we can to them. Task-number: QTBUG-103531 Change-Id: I0fd5c9c721e892ea617f0b56b8ea423e7a9f0d04 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 88f2a78594e0272d7916e13aca39611a85571937) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4c5533bba3
commit
19f9e7c045
@ -3104,10 +3104,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;
|
||||
@ -3574,8 +3574,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));
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user