summaryrefslogtreecommitdiffstats
path: root/src/network/access
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-01-26 14:38:54 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-05-04 05:21:25 +0000
commitf3af7fce4a9174fb80de22cf650435516c2f3796 (patch)
tree1132b8aad645d9e27b09cf2367866f2c10678061 /src/network/access
parent347832d7593e2369f8597bbd06213b80b3087433 (diff)
QtNetwork: eradicate Q_FOREACH loops [rvalues]
... by replacing them with C++11 range-for loops. This is the simplest of the patch series: Q_FOREACH took a copy, so we do, too. Except we don't, since we're just catching the return value that comes out of the function (RVO). We can't feed the rvalues into range-for, because they are non-const and would thus detach. Change-Id: I42c9c44d948ab1512a69d42890187bc3cf2d7e58 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/network/access')
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp3
-rw-r--r--src/network/access/qnetworkaccessftpbackend.cpp3
-rw-r--r--src/network/access/qnetworkdiskcache.cpp6
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp3
-rw-r--r--src/network/access/qnetworkreplynsurlconnectionimpl.mm3
5 files changed, 12 insertions, 6 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 7144734138..79f418f675 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -1148,7 +1148,8 @@ void QHttpNetworkConnectionPrivate::_q_hostLookupFinished(const QHostInfo &info)
if (networkLayerState == IPv4 || networkLayerState == IPv6 || networkLayerState == IPv4or6)
return;
- foreach (const QHostAddress &address, info.addresses()) {
+ const auto addresses = info.addresses();
+ for (const QHostAddress &address : addresses) {
const QAbstractSocket::NetworkLayerProtocol protocol = address.protocol();
if (protocol == QAbstractSocket::IPv4Protocol) {
if (!foundAddress) {
diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp
index 793a3b3452..153a33f782 100644
--- a/src/network/access/qnetworkaccessftpbackend.cpp
+++ b/src/network/access/qnetworkaccessftpbackend.cpp
@@ -121,7 +121,8 @@ void QNetworkAccessFtpBackend::open()
{
#ifndef QT_NO_NETWORKPROXY
QNetworkProxy proxy;
- foreach (const QNetworkProxy &p, proxyList()) {
+ const auto proxies = proxyList();
+ for (const QNetworkProxy &p : proxies) {
// use the first FTP proxy
// or no proxy at all
if (p.type() == QNetworkProxy::FtpCachingProxy
diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp
index 99e67cb463..077826ccf6 100644
--- a/src/network/access/qnetworkdiskcache.cpp
+++ b/src/network/access/qnetworkdiskcache.cpp
@@ -189,7 +189,8 @@ QIODevice *QNetworkDiskCache::prepare(const QNetworkCacheMetaData &metaData)
return 0;
}
- foreach (const QNetworkCacheMetaData::RawHeader &header, metaData.rawHeaders()) {
+ const auto headers = metaData.rawHeaders();
+ for (const auto &header : headers) {
if (header.first.toLower() == "content-length") {
const qint64 size = header.second.toLongLong();
if (size > (maximumCacheSize() * 3)/4)
@@ -639,7 +640,8 @@ bool QCacheItem::canCompress() const
{
bool sizeOk = false;
bool typeOk = false;
- foreach (const QNetworkCacheMetaData::RawHeader &header, metaData.rawHeaders()) {
+ const auto headers = metaData.rawHeaders();
+ for (const auto &header : headers) {
if (header.first.toLower() == "content-length") {
qint64 size = header.second.toLongLong();
if (size > MAX_COMPRESSION_SIZE)
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index c6173791a6..5c403250ab 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -648,7 +648,8 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
QNetworkProxy transparentProxy, cacheProxy;
// FIXME the proxy stuff should be done in the HTTP thread
- foreach (const QNetworkProxy &p, managerPrivate->queryProxy(QNetworkProxyQuery(newHttpRequest.url()))) {
+ const auto proxies = managerPrivate->queryProxy(QNetworkProxyQuery(newHttpRequest.url()));
+ for (const QNetworkProxy &p : proxies) {
// use the first proxy that works
// for non-encrypted connections, any transparent or HTTP proxy
// for encrypted, only transparent proxies
diff --git a/src/network/access/qnetworkreplynsurlconnectionimpl.mm b/src/network/access/qnetworkreplynsurlconnectionimpl.mm
index 903e168a66..58a3ba1448 100644
--- a/src/network/access/qnetworkreplynsurlconnectionimpl.mm
+++ b/src/network/access/qnetworkreplynsurlconnectionimpl.mm
@@ -365,7 +365,8 @@ QNetworkReplyNSURLConnectionImpl::QNetworkReplyNSURLConnectionImpl(QObject *pare
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:60.0];
// copy headers
- foreach (const QByteArray &header, request.rawHeaderList()) {
+ const auto headers = request.rawHeaderList();
+ for (const QByteArray &header : headers) {
QByteArray headerValue = request.rawHeader(header);
[nsRequest addValue:QString::fromUtf8(headerValue).toNSString()
forHTTPHeaderField:QString::fromUtf8(header).toNSString()];