summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-08-18 11:57:26 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-09-15 15:55:57 +0000
commit6aa935cd92deb035739e8fea329ca2c4a435de54 (patch)
treea9a3ea43af619a7a89ce39f15ea603747767a9f2 /src/network
parent251d6094abf423f96aa0f10921defb4c6a805d14 (diff)
Use QString::fromLatin1() less to avoid string allocations
QString::fromLatin1 always allocates memory, but there are cases where we can avoid/reduce allocations or/and reduce text size, e.g.: QStringBuilder expressions Fix: replace QString::fromLatin1 with QL1S QString::fromLatin1().arg(String) pattern Fix: replace with QStringBuilder Overloaded functions with QL1S arg Fix: replace QString::fromLatin1 with QL1S In rare cases if there is no overloaded function with QL1S and we have deal with string literal, replace QString::fromLatin1 with QStringLiteral. Change-Id: Iabe1a3cc0830f40ef78a0548afa4368583c31def Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp4
-rw-r--r--src/network/kernel/qnetworkinterface_unix.cpp2
-rw-r--r--src/network/kernel/qnetworkproxy_generic.cpp2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 74fc23957c..8e5cfd9497 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -319,9 +319,9 @@ void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair)
if (systemLocale == QLatin1String("C"))
acceptLanguage = QString::fromLatin1("en,*");
else if (systemLocale.startsWith(QLatin1String("en-")))
- acceptLanguage = QString::fromLatin1("%1,*").arg(systemLocale);
+ acceptLanguage = systemLocale + QLatin1String(",*");
else
- acceptLanguage = QString::fromLatin1("%1,en,*").arg(systemLocale);
+ acceptLanguage = systemLocale + QLatin1String(",en,*");
request.setHeaderField("Accept-Language", acceptLanguage.toLatin1());
}
diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp
index da53ccfe70..2fa98c0e07 100644
--- a/src/network/kernel/qnetworkinterface_unix.cpp
+++ b/src/network/kernel/qnetworkinterface_unix.cpp
@@ -488,7 +488,7 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
interfaces = createInterfaces(interfaceListing);
for (ifaddrs *ptr = interfaceListing; ptr; ptr = ptr->ifa_next) {
// Find the interface
- QString name = QString::fromLatin1(ptr->ifa_name);
+ QLatin1String name(ptr->ifa_name);
QNetworkInterfacePrivate *iface = 0;
QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin();
for ( ; if_it != interfaces.end(); ++if_it)
diff --git a/src/network/kernel/qnetworkproxy_generic.cpp b/src/network/kernel/qnetworkproxy_generic.cpp
index e69870a98c..3ff0cc5168 100644
--- a/src/network/kernel/qnetworkproxy_generic.cpp
+++ b/src/network/kernel/qnetworkproxy_generic.cpp
@@ -79,7 +79,7 @@ static bool ignoreProxyFor(const QNetworkProxyQuery &query)
if (!peerHostName.startsWith('.'))
peerHostName.prepend('.');
- if (peerHostName.endsWith(QString::fromLatin1(token)))
+ if (peerHostName.endsWith(QLatin1String(token)))
return true;
}