From 0ef4e6d4bfdb4a783167bc0cddeeb2059183bf9b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 17 Feb 2022 09:11:55 +0100 Subject: [PATCH] Use QtMiscUtils::toAsciiLower() around the code ... instead of self-rolled versions in at least three TUs. QByteArray's asciiLower() cannot be completely removed, yet, because it's used for indirect calls. Change-Id: Icf4e7605184f0a1157967c78cbd7632b283c4a9d Reviewed-by: Thiago Macieira --- src/corelib/text/qbytearray.cpp | 2 +- src/corelib/text/qlocale.cpp | 11 ++--------- src/corelib/text/qstring.cpp | 16 +++++----------- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 9f768484b6..d847dd4bee 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -4196,7 +4196,7 @@ QByteArray QByteArray::number(double n, char format, int precision) { QLocaleData::DoubleForm form = QLocaleData::DFDecimal; - switch (asciiLower(format)) { + switch (QtMiscUtils::toAsciiLower(format)) { case 'f': form = QLocaleData::DFDecimal; break; diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 7571b649f0..1811304f51 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -68,6 +68,7 @@ QT_WARNING_DISABLE_GCC("-Wfree-nonheap-object") // false positive tracking #include "qvarlengtharray.h" #include "qstringbuilder.h" #include "private/qnumeric_p.h" +#include "private/qtools_p.h" #include #ifndef QT_NO_SYSTEMLOCALE # include "qmutex.h" @@ -2629,14 +2630,6 @@ static bool qIsUpper(char c) return c >= 'A' && c <= 'Z'; } -static char qToLower(char c) -{ - if (c >= 'A' && c <= 'Z') - return c - 'A' + 'a'; - else - return c; -} - /*! \overload Returns a string representing the floating-point number \a f. @@ -2678,7 +2671,7 @@ QString QLocale::toString(double f, char format, int precision) const QLocaleData::DoubleForm form = QLocaleData::DFDecimal; uint flags = qIsUpper(format) ? QLocaleData::CapitalEorX : 0; - switch (qToLower(format)) { + switch (QtMiscUtils::toAsciiLower(format)) { case 'f': form = QLocaleData::DFDecimal; break; diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 6be5cd668e..72c839a478 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -45,6 +45,7 @@ #endif #include "qunicodetables_p.h" #include +#include #include "qlocale_tools_p.h" #include "private/qsimd_p.h" #include @@ -130,13 +131,6 @@ inline bool qIsDigit(char ch) return ch >= '0' && ch <= '9'; } -inline char qToLower(char ch) -{ - if (ch >= 'A' && ch <= 'Z') - return ch - 'A' + 'a'; - else - return ch; -} template char32_t foldCaseHelper(Pointer ch, Pointer start) = delete; @@ -6949,7 +6943,7 @@ QString QString::vasprintf(const char *cformat, va_list ap) flags |= QLocaleData::CapitalEorX; int base = 10; - switch (qToLower(*c)) { + switch (QtMiscUtils::toAsciiLower(*c)) { case 'o': base = 8; break; case 'u': @@ -6980,7 +6974,7 @@ QString QString::vasprintf(const char *cformat, va_list ap) flags |= QLocaleData::CapitalEorX; QLocaleData::DoubleForm form = QLocaleData::DFDecimal; - switch (qToLower(*c)) { + switch (QtMiscUtils::toAsciiLower(*c)) { case 'e': form = QLocaleData::DFExponent; break; case 'a': // not supported - decimal form used instead case 'f': form = QLocaleData::DFDecimal; break; @@ -7568,7 +7562,7 @@ QString QString::number(double n, char format, int precision) { QLocaleData::DoubleForm form = QLocaleData::DFDecimal; - switch (qToLower(format)) { + switch (QtMiscUtils::toAsciiLower(format)) { case 'f': form = QLocaleData::DFDecimal; break; @@ -8452,7 +8446,7 @@ QString QString::arg(double a, int fieldWidth, char format, int precision, QChar flags |= QLocaleData::CapitalEorX; QLocaleData::DoubleForm form = QLocaleData::DFDecimal; - switch (qToLower(format)) { + switch (QtMiscUtils::toAsciiLower(format)) { case 'f': form = QLocaleData::DFDecimal; break;