From 6c624c80fd9f2b5d43dabf955ef42657c8d029bd Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 1 Sep 2022 18:24:30 +0200 Subject: [PATCH] Avoid recomputing DST-ness for time-zone when already known MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a QDateTime is constructed it determines whether daylight-saving time is in effect and records it in its status field. So consult that cached answer first, before asking the time-zone backend to work out the answer the slow way. Change-Id: I1d380d41f28a9b866216ac0f65425c30a8988cac Reviewed-by: MÃ¥rten Nordheim --- src/corelib/time/qdatetime.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 865e9befdf1..418466033de 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -3613,6 +3613,10 @@ bool QDateTime::isDaylightTime() const break; #else Q_ASSERT(d->m_timeZone.isValid()); + if (auto dst = extractDaylightStatus(getStatus(d)); + dst != QDateTimePrivate::UnknownDaylightTime) { + return dst == QDateTimePrivate::DaylightTime; + } return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch()); #endif // timezone case Qt::LocalTime: {