diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2021-07-29 17:58:06 +0200 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2021-08-17 00:31:26 +0200 |
commit | de9c03dc6eff8fd54c95d1aa533eabecaad20417 (patch) | |
tree | 189cde7a83f0b2f940299cd05cdc278e6cf6a609 /src/corelib/text/qbytearray.cpp | |
parent | e5e8e4f59ba4c3d59303220a57677360992eb553 (diff) |
QByteArray: Disentangle number(double) from QLocale
Previously number(double) would go through QLocale which takes a lot of
factors into consideration (which we don't need in this case) and
outputs a QString in the end, which we then have to convert back to
QByteArray. Avoid all that extra work and format it directly into a
QByteArray.
The other number() functions do not use QLocale, so are left alone for now.
Task-number: QTBUG-88484
Change-Id: I4c2eaf101a55ba16e858f95017fb171589a0184e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/text/qbytearray.cpp')
-rw-r--r-- | src/corelib/text/qbytearray.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 23db7db3e2..d1efd2c35a 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -4110,13 +4110,8 @@ QByteArray QByteArray::number(qulonglong n, int base) QByteArray QByteArray::number(double n, char format, int precision) { QLocaleData::DoubleForm form = QLocaleData::DFDecimal; - uint flags = QLocaleData::ZeroPadExponent; - char lower = asciiLower(uchar(format)); - if (format != lower) - flags |= QLocaleData::CapitalEorX; - - switch (lower) { + switch (asciiLower(format)) { case 'f': form = QLocaleData::DFDecimal; break; @@ -4133,7 +4128,7 @@ QByteArray QByteArray::number(double n, char format, int precision) break; } - return QLocaleData::c()->doubleToString(n, precision, form, -1, flags).toUtf8(); + return qdtoAscii(n, form, precision, isUpperCaseAscii(format)); } /*! |