summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-01-21 14:35:25 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-02-15 19:38:59 +0000
commit1d2efe1f27bedcbaa157ef4e82b8eda33dda46ad (patch)
tree03fe10da803183531b8d4eec213647fa48f15da3 /src/corelib
parent85ecc44eee3eb8112faf9989570664ed9302073f (diff)
QDateTime: micro-optimize QDebug op<<
Instead of constructing a QString that describes the QDateTime instance, stream the constituents of the string into QDebug directly, using op<< for Q_ENUM, now that it's available. Adapt test to new format of enums. Effects on Linux GCC 4.9 stripped release builds: text -1068B data +-0B relocs +-0 Change-Id: I1a5ce28904edd7d0f6c8d982fd41c52e3536e036 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qdatetime.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index eb82113f94..adfcbcecf0 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -5007,26 +5007,23 @@ QDebug operator<<(QDebug dbg, const QTime &time)
QDebug operator<<(QDebug dbg, const QDateTime &date)
{
QDebugStateSaver saver(dbg);
- QString spec;
+ dbg.nospace() << "QDateTime(" << date.toString(QStringLiteral("yyyy-MM-dd HH:mm:ss.zzz t"))
+ << ' ' << date.timeSpec();
switch (date.d->m_spec) {
case Qt::UTC:
- spec = QStringLiteral(" Qt::UTC");
break;
case Qt::OffsetFromUTC:
- spec = QString::fromLatin1(" Qt::OffsetFromUTC %1s").arg(date.offsetFromUtc());
+ dbg << ' ' << date.offsetFromUtc() << 's';
break;
case Qt::TimeZone:
#ifndef QT_BOOTSTRAPPED
- spec = QStringLiteral(" Qt::TimeZone ") + QString::fromLatin1(date.timeZone().id());
+ dbg << ' ' << date.timeZone().id();
break;
#endif // QT_BOOTSTRAPPED
case Qt::LocalTime:
- spec = QStringLiteral(" Qt::LocalTime");
break;
}
- QString output = date.toString(QStringLiteral("yyyy-MM-dd HH:mm:ss.zzz t")) + spec;
- dbg.nospace() << "QDateTime(" << output << ')';
- return dbg;
+ return dbg << ')';
}
#endif