summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-10-23 16:32:59 +0200
committerMarc Mutz <marc.mutz@kdab.com>2015-10-27 11:10:01 +0000
commitf8eeabcf5ca4615fcb3ed783dbd321f4998a7651 (patch)
treec641a8f918eac90ac581f83bc51392847a0bd135
parent39e023b805cf2be207ef7086f6951e789e020bda (diff)
QNetworkReplyHttpImpl: convert some 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 QDateTime is only used to compare against a copy of itself, adjusted by some seconds, which doen't care which TZ the date-time is in, to get a time_t, which is much faster done from a UTC time, and to calculate the seconds to expirationTime, which, from a quick glance around, seem to be mostly, if not exclusively, in UTC. secsTo() works across time zones, but the comparison between UTC date-times is fastest. Credits to Milian Wolff, from whose QtWS15 talk this advice is taken. Change-Id: I22aa5350b29493f01fb503ef5ec68a964ca95cf3 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 63fca2bda2..c29b132217 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -512,7 +512,7 @@ bool QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(QHttpNetworkRequest &h
return false;
}
- QDateTime currentDateTime = QDateTime::currentDateTime();
+ QDateTime currentDateTime = QDateTime::currentDateTimeUtc();
QDateTime expirationDate = metaData.expirationDate();
bool response_is_fresh;
@@ -545,7 +545,7 @@ bool QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(QHttpNetworkRequest &h
date_value = dateHeader.toTime_t();
}
- int now = currentDateTime.toUTC().toTime_t();
+ int now = currentDateTime.toTime_t();
int request_time = now;
int response_time = now;