QTextStream numbers parsing optimizations

QLocale::c() creates temporary QLocale object for the sake of comparison
which is sub-optimal much like QLocale::system() but QLocale::c() can be
cached in the future or optimized in other ways

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-03-14 20:06:57 +02:00
parent f4bbfdc17a
commit 692168326a

View file

@ -1646,7 +1646,7 @@ QTextStreamPrivate::NumberParsingStatus QTextStreamPrivate::getNumber(qulonglong
if (ch.isDigit()) {
val *= 10;
val += ch.digitValue();
} else if (locale != QLocale::c() && ch == locale.groupSeparator()) {
} else if (locale.language() != QLocale::C && ch == locale.groupSeparator()) {
continue;
} else {
ungetChar(ch);
@ -1797,7 +1797,7 @@ bool QTextStreamPrivate::getReal(double *f)
else if (lc == locale.negativeSign().toLower()
|| lc == locale.positiveSign().toLower())
input = InputSign;
else if (locale != QLocale::c() // backward-compatibility
else if (locale.language() != QLocale::C // backward-compatibility
&& lc == locale.groupSeparator().toLower())
input = InputDigit; // well, it isn't a digit, but no one cares.
else