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>
This commit is contained in:
parent
39e023b805
commit
f8eeabcf5c
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user