summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale_tools.cpp
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2021-07-29 17:58:06 +0200
committerMårten Nordheim <marten.nordheim@qt.io>2021-08-17 00:31:26 +0200
commitde9c03dc6eff8fd54c95d1aa533eabecaad20417 (patch)
tree189cde7a83f0b2f940299cd05cdc278e6cf6a609 /src/corelib/text/qlocale_tools.cpp
parente5e8e4f59ba4c3d59303220a57677360992eb553 (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/qlocale_tools.cpp')
-rw-r--r--src/corelib/text/qlocale_tools.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/corelib/text/qlocale_tools.cpp b/src/corelib/text/qlocale_tools.cpp
index dc0460fa4e..15933c3644 100644
--- a/src/corelib/text/qlocale_tools.cpp
+++ b/src/corelib/text/qlocale_tools.cpp
@@ -628,6 +628,7 @@ static constexpr int digits(int number)
return i;
}
+// Used generically for both QString and QByteArray
template <typename T>
static T dtoString(double d, QLocaleData::DoubleForm form, int precision, bool uppercase)
{
@@ -783,4 +784,9 @@ QString qdtoBasicLatin(double d, QLocaleData::DoubleForm form, int precision, bo
return dtoString<QString>(d, form, precision, uppercase);
}
+QByteArray qdtoAscii(double d, QLocaleData::DoubleForm form, int precision, bool uppercase)
+{
+ return dtoString<QByteArray>(d, form, precision, uppercase);
+}
+
QT_END_NAMESPACE