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>
bb10
Edward Welbourne 2016-03-08 13:18:39 +01:00
parent d0b54cede8
commit 2027c0b926
1 changed files with 4 additions and 7 deletions

View File

@ -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")) {