diff options
author | Robin Burchell <robin.burchell@viroteck.net> | 2014-09-14 15:57:29 +0200 |
---|---|---|
committer | Robin Burchell <robin.burchell@viroteck.net> | 2014-09-15 12:33:08 +0200 |
commit | 1c4786389d0adb252e2c61e62652e38c8189c889 (patch) | |
tree | 8d6b67535c0ea5ffea1f999e636661c986347df5 /src/corelib/tools/qdatetime.cpp | |
parent | 5857809cc5305423b6beb07064e78358a6e16857 (diff) |
QDateTime: Micro-optimize by using QString::fromLatin1 instead of QString::fromUtf8.
This data is clearly not (and will never be) utf8 data, so using fromLatin1
avoids the (slightly more expensive) utf8 mangling.
I didn't see any significant impact on benchmarks, but I also wasn't
specifically collecting data when making this change.
Change-Id: I45190d40b2caccf15b1f9a1ae5b7dcd08cbd541f
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/tools/qdatetime.cpp')
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index c4567a5097..1cd0a0d6d8 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -906,18 +906,18 @@ QString QDate::toString(Qt::DateFormat format) const #ifndef QT_NO_TEXTDATE case Qt::TextDate: getDateFromJulianDay(jd, &y, &m, &d); - return QString::fromUtf8("%1 %2 %3 %4").arg(shortDayName(dayOfWeek())) - .arg(shortMonthName(m)) - .arg(d) - .arg(y); + return QString::fromLatin1("%1 %2 %3 %4").arg(shortDayName(dayOfWeek())) + .arg(shortMonthName(m)) + .arg(d) + .arg(y); #endif case Qt::ISODate: getDateFromJulianDay(jd, &y, &m, &d); if (y < 0 || y > 9999) return QString(); - return QString::fromUtf8("%1-%2-%3").arg(y, 4, 10, QLatin1Char('0')) - .arg(m, 2, 10, QLatin1Char('0')) - .arg(d, 2, 10, QLatin1Char('0')); + return QString::fromLatin1("%1-%2-%3").arg(y, 4, 10, QLatin1Char('0')) + .arg(m, 2, 10, QLatin1Char('0')) + .arg(d, 2, 10, QLatin1Char('0')); } } @@ -1656,9 +1656,9 @@ QString QTime::toString(Qt::DateFormat format) const case Qt::ISODate: case Qt::TextDate: default: - return QString::fromUtf8("%1:%2:%3").arg(hour(), 2, 10, QLatin1Char('0')) - .arg(minute(), 2, 10, QLatin1Char('0')) - .arg(second(), 2, 10, QLatin1Char('0')); + return QString::fromLatin1("%1:%2:%3").arg(hour(), 2, 10, QLatin1Char('0')) + .arg(minute(), 2, 10, QLatin1Char('0')) + .arg(second(), 2, 10, QLatin1Char('0')); } } @@ -3603,11 +3603,11 @@ QString QDateTime::toString(Qt::DateFormat format) const QTime tm; d->getDateTime(&dt, &tm); //We cant use date.toString(Qt::TextDate) as we need to insert the time before the year - buf = QString::fromUtf8("%1 %2 %3 %4 %5").arg(dt.shortDayName(dt.dayOfWeek())) - .arg(dt.shortMonthName(dt.month())) - .arg(dt.day()) - .arg(tm.toString(Qt::TextDate)) - .arg(dt.year()); + buf = QString::fromLatin1("%1 %2 %3 %4 %5").arg(dt.shortDayName(dt.dayOfWeek())) + .arg(dt.shortMonthName(dt.month())) + .arg(dt.day()) + .arg(tm.toString(Qt::TextDate)) + .arg(dt.year()); if (timeSpec() != Qt::LocalTime) { buf += QStringLiteral(" GMT"); if (d->m_spec == Qt::OffsetFromUTC) @@ -4994,7 +4994,7 @@ QDebug operator<<(QDebug dbg, const QDateTime &date) spec = QStringLiteral(" Qt::UTC"); break; case Qt::OffsetFromUTC: - spec = QString::fromUtf8(" Qt::OffsetFromUTC %1s").arg(date.offsetFromUtc()); + spec = QString::fromLatin1(" Qt::OffsetFromUTC %1s").arg(date.offsetFromUtc()); break; case Qt::TimeZone: #ifndef QT_BOOTSTRAPPED |