From a681b90418aae8b6ffffc0c6ba79d4e1c257901b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 23 Oct 2015 16:32:59 +0200 Subject: QNetworkAccessCache: convert QDateTime::currentDateTime() to currentDateTimeUtc() The latter is much faster as it doesn't have to deal with time zones. This change is safe, because the timestamp member is only ever handled inside, and the calculation of the time difference does not depend on any particular time zone. Credits to Milian Wolff, from whose QtWS15 talk this advice is taken. Change-Id: I6c9190a4253ce5972871ab1f12870f8ae9891966 Reviewed-by: Milian Wolff Reviewed-by: Lars Knoll --- src/network/access/qnetworkaccesscache.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/network/access/qnetworkaccesscache.cpp') diff --git a/src/network/access/qnetworkaccesscache.cpp b/src/network/access/qnetworkaccesscache.cpp index 19316bda75..3d029f118b 100644 --- a/src/network/access/qnetworkaccesscache.cpp +++ b/src/network/access/qnetworkaccesscache.cpp @@ -151,7 +151,7 @@ void QNetworkAccessCache::linkEntry(const QByteArray &key) oldest = node; } - node->timestamp = QDateTime::currentDateTime().addSecs(ExpiryTime); + node->timestamp = QDateTime::currentDateTimeUtc().addSecs(ExpiryTime); newest = node; } @@ -190,7 +190,7 @@ void QNetworkAccessCache::updateTimer() if (!oldest) return; - int interval = QDateTime::currentDateTime().secsTo(oldest->timestamp); + int interval = QDateTime::currentDateTimeUtc().secsTo(oldest->timestamp); if (interval <= 0) { interval = 0; } else { @@ -216,7 +216,7 @@ bool QNetworkAccessCache::emitEntryReady(Node *node, QObject *target, const char void QNetworkAccessCache::timerEvent(QTimerEvent *) { // expire old items - QDateTime now = QDateTime::currentDateTime(); + const QDateTime now = QDateTime::currentDateTimeUtc(); while (oldest && oldest->timestamp < now) { Node *next = oldest->newer; -- cgit v1.2.3