From d3279b32173a37694a677055520f803d04d422bd Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 11 May 2016 23:38:21 -0700 Subject: QDateTime: fix the massageAdjustedDateTime differently Instead of using a macro for maybe passing an extra parameter, pass the d pointer and let the function decide what to use and what not to use. Change-Id: I06bae9392f534e45b3f1ffff144dbeb68a30cb48 Reviewed-by: Lars Knoll Reviewed-by: Edward Welbourne --- src/corelib/tools/qdatetime.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 9c07241939..708526c8f3 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3587,12 +3587,7 @@ QString QDateTime::toString(const QString& format) const } #endif //QT_NO_DATESTRING -static void massageAdjustedDateTime(Qt::TimeSpec spec, -#ifndef QT_BOOTSTRAPPED - const QTimeZone &zone, -#endif // QT_BOOTSTRAPPED - QDate *date, - QTime *time) +static inline void massageAdjustedDateTime(const QDateTimePrivate *d, QDate *date, QTime *time) { /* If we have just adjusted to a day with a DST transition, our given time @@ -3606,20 +3601,16 @@ static void massageAdjustedDateTime(Qt::TimeSpec spec, (far more common) other cases; and it makes little difference, as the two answers do then differ only in DST-ness.) */ + auto spec = d->spec(); if (spec == Qt::LocalTime) { QDateTimePrivate::DaylightStatus status = QDateTimePrivate::UnknownDaylightTime; localMSecsToEpochMSecs(timeToMSecs(*date, *time), &status, date, time); #ifndef QT_BOOTSTRAPPED } else if (spec == Qt::TimeZone) { - QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time), zone, date, time); + QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time), d->m_timeZone, date, time); #endif // QT_BOOTSTRAPPED } } -#ifdef QT_BOOTSTRAPPED // Avoid duplicate #if-ery in uses. -#define MASSAGEADJUSTEDDATETIME(s, z, d, t) massageAdjustedDateTime(s, d, t) -#else -#define MASSAGEADJUSTEDDATETIME(s, z, d, t) massageAdjustedDateTime(s, z, d, t) -#endif // QT_BOOTSTRAPPED /*! Returns a QDateTime object containing a datetime \a ndays days @@ -3642,7 +3633,7 @@ QDateTime QDateTime::addDays(qint64 ndays) const QDate &date = p.first; QTime &time = p.second; date = date.addDays(ndays); - MASSAGEADJUSTEDDATETIME(d->spec(), d->m_timeZone, &date, &time); + massageAdjustedDateTime(dt.d, &date, &time); dt.d->setDateTime(date, time); return dt; } @@ -3668,7 +3659,7 @@ QDateTime QDateTime::addMonths(int nmonths) const QDate &date = p.first; QTime &time = p.second; date = date.addMonths(nmonths); - MASSAGEADJUSTEDDATETIME(d->spec(), d->m_timeZone, &date, &time); + massageAdjustedDateTime(dt.d, &date, &time); dt.d->setDateTime(date, time); return dt; } @@ -3694,11 +3685,10 @@ QDateTime QDateTime::addYears(int nyears) const QDate &date = p.first; QTime &time = p.second; date = date.addYears(nyears); - MASSAGEADJUSTEDDATETIME(d->spec(), d->m_timeZone, &date, &time); + massageAdjustedDateTime(dt.d, &date, &time); dt.d->setDateTime(date, time); return dt; } -#undef MASSAGEADJUSTEDDATETIME /*! Returns a QDateTime object containing a datetime \a s seconds -- cgit v1.2.3