QDateTime - Optimize refreshDateTime()

A small optimization to the private refreshDateTime() function, improves
standard performance tests by 0.3 msecs per iteration for affected
functions, e.g. isValid() and offsetFromUtc() improve from 5.4 to 5.1.

Change-Id: Ie67812649ef244388b484af35848b09d92dee38a
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
John Layt 2013-09-28 16:46:19 +02:00 committed by The Qt Project
parent 1da1259c28
commit 24733dea6c

View File

@ -2765,9 +2765,6 @@ void QDateTimePrivate::refreshDateTime()
}
// We have a valid date and time and a Qt::LocalTime or Qt::TimeZone that needs calculating
QDate date;
QTime time;
getDateTime(&date, &time);
// LocalTime and TimeZone might fall into "missing" DaylightTime transition hour
// Calling toEpochMSecs will adjust the returned date/time if it does
QDate testDate;
@ -2781,7 +2778,7 @@ void QDateTimePrivate::refreshDateTime()
epochMSecs = zoneMSecsToEpochMSecs(m_msecs, m_timeZone, &testDate, &testTime);
#endif // QT_BOOTSTRAPPED
}
if (testDate == date && testTime == time) {
if (timeToMSecs(testDate, testTime) == m_msecs) {
setValidDateTime();
// Cache the offset to use in toMSecsSinceEpoch()
m_offsetFromUtc = (m_msecs - epochMSecs) / 1000;