diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 56deeb7cf75..240cc2ea959 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; @@ -431,6 +426,16 @@ QByteArray QDebug::timeUnit(qint64 num, qint64 den) return QByteArray(buf, len + strlen(unit)); } +/*! + \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 diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 7390a9c8bce..8469a4a8206 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -68,7 +68,7 @@ class QT6_ONLY(Q_CORE_EXPORT) QDebug : public QIODeviceBase QT7_ONLY(Q_CORE_EXPORT) void putUcs4(uint ucs4); QT7_ONLY(Q_CORE_EXPORT) void putString(const QChar *begin, size_t length); QT7_ONLY(Q_CORE_EXPORT) void putByteArray(const char *begin, size_t length, Latin1Content content); - QT7_ONLY(Q_CORE_EXPORT) static QByteArray timeUnit(qint64 num, qint64 den); + QT7_ONLY(Q_CORE_EXPORT) void putTimeUnit(qint64 num, qint64 den); public: explicit QDebug(QIODevice *device) : stream(new Stream(device)) {} explicit QDebug(QString *string) : stream(new Stream(string)) {} @@ -194,7 +194,8 @@ public: template QDebug &operator<<(std::chrono::duration duration) { - stream->ts << duration.count() << timeUnit(Period::num, Period::den); + stream->ts << duration.count(); + putTimeUnit(Period::num, Period::den); return maybeSpace(); }