diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-10-23 16:32:59 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-10-26 09:00:26 +0000 |
commit | a681b90418aae8b6ffffc0c6ba79d4e1c257901b (patch) | |
tree | d9bf936614062521a1df765abb74ea36e3bb174f /src | |
parent | 4f4da7462bd1ea81c15136d90a0ba71aefbf793e (diff) |
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 <milian.wolff@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/network/access/qnetworkaccesscache.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
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; |