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>
This commit is contained in:
parent
4f4da7462b
commit
a681b90418
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user