network: use CIS compare more

to reduce allocations

Change-Id: I648518fd152a834bbdc6afcedb693f02c1b13af1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Anton Kudryavtsev 2023-11-01 13:58:52 +03:00
parent fcab2b88af
commit 0bd9265867
2 changed files with 11 additions and 12 deletions

View File

@ -985,9 +985,8 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(QByteArray
case ';':
// new field in the cookie
field = nextField(cookieString, position, false);
field.first = field.first.toLower(); // everything but the NAME=VALUE is case-insensitive
if (field.first == "expires") {
if (field.first.compare("expires", Qt::CaseInsensitive) == 0) {
position -= field.second.size();
int end;
for (end = position; end < length; ++end)
@ -1000,7 +999,7 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(QByteArray
if (dt.isValid())
cookie.setExpirationDate(dt);
//if unparsed, ignore the attribute but not the whole cookie (RFC6265 section 5.2.1)
} else if (field.first == "domain") {
} else if (field.first.compare("domain", Qt::CaseInsensitive) == 0) {
QByteArrayView rawDomain = field.second;
//empty domain should be ignored (RFC6265 section 5.2.3)
if (!rawDomain.isEmpty()) {
@ -1021,7 +1020,7 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(QByteArray
return result;
}
}
} else if (field.first == "max-age") {
} else if (field.first.compare("max-age", Qt::CaseInsensitive) == 0) {
bool ok = false;
int secs = field.second.toInt(&ok);
if (ok) {
@ -1033,7 +1032,7 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(QByteArray
}
}
//if unparsed, ignore the attribute but not the whole cookie (RFC6265 section 5.2.2)
} else if (field.first == "path") {
} else if (field.first.compare("path", Qt::CaseInsensitive) == 0) {
if (field.second.startsWith('/')) {
// ### we should treat cookie paths as an octet sequence internally
// However RFC6265 says we should assume UTF-8 for presentation as a string
@ -1043,11 +1042,11 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(QByteArray
// and also IETF test case path0030 which has valid and empty path in the same cookie
cookie.setPath(QString());
}
} else if (field.first == "secure") {
} else if (field.first.compare("secure", Qt::CaseInsensitive) == 0) {
cookie.setSecure(true);
} else if (field.first == "httponly") {
} else if (field.first.compare("httponly", Qt::CaseInsensitive) == 0) {
cookie.setHttpOnly(true);
} else if (field.first == "samesite") {
} else if (field.first.compare("samesite", Qt::CaseInsensitive) == 0) {
cookie.setSameSitePolicy(sameSiteFromRawString(field.second));
} else {
// ignore unknown fields in the cookie (RFC6265 section 5.2, rule 6)

View File

@ -289,9 +289,9 @@ QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query)
// No PAC, decide which proxy we're looking for based on the query
// try the protocol-specific proxy
QString protocol = query.protocolTag().toLower();
const QString protocol = query.protocolTag();
QNetworkProxy protocolSpecificProxy;
if (protocol == "http"_L1) {
if (protocol.compare("http"_L1, Qt::CaseInsensitive) == 0) {
protocolSpecificProxy =
proxyFromDictionary(dict, QNetworkProxy::HttpProxy,
kCFNetworkProxiesHTTPEnable,
@ -318,13 +318,13 @@ QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query)
}
#else
bool isHttps = false;
if (protocol == "ftp"_L1) {
if (protocol.compare("ftp"_L1, Qt::CaseInsensitive) == 0) {
protocolSpecificProxy =
proxyFromDictionary(dict, QNetworkProxy::FtpCachingProxy,
kCFNetworkProxiesFTPEnable,
kCFNetworkProxiesFTPProxy,
kCFNetworkProxiesFTPPort);
} else if (protocol == "https"_L1) {
} else if (protocol.compare("https"_L1, Qt::CaseInsensitive) == 0) {
isHttps = true;
protocolSpecificProxy =
proxyFromDictionary(dict, QNetworkProxy::HttpProxy,