summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkreplyhttpimpl.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@theqtcompany.com>2016-03-08 13:18:39 +0100
committerEdward Welbourne <edward.welbourne@theqtcompany.com>2016-03-08 13:25:54 +0000
commit2027c0b926d1fc41c929616e209e31fa11b5dc4d (patch)
tree4d15a8f3aeec58bd3b25800285f701f62b5c8286 /src/network/access/qnetworkreplyhttpimpl.cpp
parentd0b54cede8d8ea0b8431c64abb51d0cd1a71327b (diff)
Duplicate trivial code for clarity on early return.
Having a variable in which to store a function's return in two branches of a switch in order to return if either was true saved little relative to just testing the function in each case and returning in situ, which reads more clearly. Change-Id: Ibd95a95721eaa6fc4861b10e723038b96caf269a Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
Diffstat (limited to 'src/network/access/qnetworkreplyhttpimpl.cpp')
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 04d391a14c..afb7a204e2 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -676,18 +676,19 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
if (newHttpRequest.attribute(QNetworkRequest::FollowRedirectsAttribute).toBool())
httpRequest.setFollowRedirects(true);
- bool loadedFromCache = false;
httpRequest.setPriority(convert(newHttpRequest.priority()));
switch (operation) {
case QNetworkAccessManager::GetOperation:
httpRequest.setOperation(QHttpNetworkRequest::Get);
- loadedFromCache = loadFromCacheIfAllowed(httpRequest);
+ if (loadFromCacheIfAllowed(httpRequest))
+ return; // no need to send the request! :)
break;
case QNetworkAccessManager::HeadOperation:
httpRequest.setOperation(QHttpNetworkRequest::Head);
- loadedFromCache = loadFromCacheIfAllowed(httpRequest);
+ if (loadFromCacheIfAllowed(httpRequest))
+ return; // no need to send the request! :)
break;
case QNetworkAccessManager::PostOperation:
@@ -719,10 +720,6 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
break; // can't happen
}
- if (loadedFromCache) {
- return; // no need to send the request! :)
- }
-
QList<QByteArray> headers = newHttpRequest.rawHeaderList();
if (resumeOffset != 0) {
if (headers.contains("Range")) {