diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-03-06 10:00:09 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-03-09 15:26:24 +0000 |
commit | 75c6bd54d7e056e2818f942f9e40b897f575fd34 (patch) | |
tree | df9cfab83b6d6a4aa8a1821f4103a3beb48c8efe /src/corelib/tools/qbytearray.cpp | |
parent | 261c0dedac1d97b5960d27eedaa017d45050b654 (diff) |
Avoid copying QByteArray created via fromRawData in toDouble
qt_asciiToDouble accepts a length parameter, so we can just pass
that through. No need for explicitly null-terminating, which is
where the copy of the data would be made.
Change-Id: I4e7921541f03295a2fae6171b35157084ff3ed8c
Fixes: QTBUG-65748
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qbytearray.cpp')
-rw-r--r-- | src/corelib/tools/qbytearray.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 64674ddc00..8770100749 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -4135,10 +4135,9 @@ ushort QByteArray::toUShort(bool *ok, int base) const double QByteArray::toDouble(bool *ok) const { - QByteArray nulled = nulTerminated(); bool nonNullOk = false; int processed = 0; - double d = qt_asciiToDouble(nulled.constData(), nulled.length(), + double d = qt_asciiToDouble(constData(), size(), nonNullOk, processed, WhitespacesAllowed); if (ok) *ok = nonNullOk; |