QLocaleData::validateChars(): exploit last to detect first iteration

Checking the value of last, instead of the index, prepares the way for
using QStringIterator here.

Change-Id: Ided0530413211e918acd406ebdb37f16006ef07d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Edward Welbourne 2022-11-01 17:40:33 +01:00
parent df8d26f309
commit 23a854c3a6
1 changed files with 2 additions and 2 deletions

View File

@ -4022,7 +4022,7 @@ bool QLocaleData::validateChars(QStringView str, NumberMode numMode, QByteArray
enum { Whole, Fractional, Exponent } state = Whole;
const bool scientific = numMode == DoubleScientificMode;
char last = 0;
char last = '\0';
for (qsizetype i = 0; i < str.size();) {
const QStringView in = str.mid(i, str.at(i).isHighSurrogate() ? 2 : 1);
@ -4064,7 +4064,7 @@ bool QLocaleData::validateChars(QStringView str, NumberMode numMode, QByteArray
case '+':
case '-':
// A sign can only appear at the start or after the e of scientific:
if (i != 0 && !(scientific && last == 'e'))
if (last != '\0' && !(scientific && last == 'e'))
return false;
break;