summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qdebug.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-07-07 13:10:43 +0200
committerAhmad Samir <a.samirh78@gmail.com>2023-07-10 13:51:52 +0000
commit568ab62185bfa7876db4d8804101a8f946b04898 (patch)
tree7ec4d509420f1bc55afe9236a8ceade4811f3848 /src/corelib/io/qdebug.cpp
parentd4e3d008fe95be309f40e25cb08b0639c926bf76 (diff)
QDebug: rewrite timeUnit() into putTimeUnit()
This avoids us committing to the QByteArray return value, which is overkill for short strings. Instead, pull the streaming of the unit behind the ABI boundary, so we're free to change the implementation to either stream directly or use SSO'ed std::string. Pick-to: 6.6 Change-Id: I10927acb9d64077d9018b667958ca16be218012a Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/corelib/io/qdebug.cpp')
-rw-r--r--src/corelib/io/qdebug.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp
index f8402dfeda..1671914f5e 100644
--- a/src/corelib/io/qdebug.cpp
+++ b/src/corelib/io/qdebug.cpp
@@ -347,12 +347,7 @@ void QDebug::putByteArray(const char *begin, size_t length, Latin1Content conten
}
}
-/*!
- \since 6.6
- \internal
- Helper to the std::chrono::duration debug streaming output.
- */
-QByteArray QDebug::timeUnit(qint64 num, qint64 den)
+static QByteArray timeUnit(qint64 num, qint64 den)
{
using namespace std::chrono;
using namespace q20::chrono;
@@ -432,6 +427,16 @@ QByteArray QDebug::timeUnit(qint64 num, qint64 den)
}
/*!
+ \since 6.6
+ \internal
+ Helper to the std::chrono::duration debug streaming output.
+ */
+void QDebug::putTimeUnit(qint64 num, qint64 den)
+{
+ stream->ts << timeUnit(num, den); // ### optimize
+}
+
+/*!
\fn QDebug::swap(QDebug &other)
\since 5.0