QLocaleData::numberToCLocale(): make discarding of grouping overt

If grouping isn't allowed, return early on hitting any.
Make the elision of grouping from the converted string easier to see.

Change-Id: I452d1e2b64612cd3ce534907a4b9aac652669ba5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2022-11-01 16:00:04 +01:00
parent 8359436751
commit 80aba027af

View File

@ -3969,10 +3969,6 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o
last_separator_idx = idx;
digitsInGroup = 0;
// don't add the group separator
idx += in.size();
continue;
} else if (out == '.' || idx == exponent_idx) {
// Were there enough digits since the last separator?
if (last_separator_idx != -1 && digitsInGroup != m_grouping_least)
@ -3985,9 +3981,12 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o
} else if (out >= '0' && out <= '9') {
digitsInGroup++;
}
} else if (out == ',') {
return false;
}
result->append(out);
if (out != ',') // Leave group separators out of the result.
result->append(out);
idx += in.size();
}