From 11a68f13e9699206309a9ec82e7acab0b8a3a40e Mon Sep 17 00:00:00 2001 From: Anton Kudryavtsev Date: Mon, 30 Oct 2023 18:54:27 +0300 Subject: [PATCH] qnetworkcookiejar: optimize validateCookie MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use string view more to reduce allocations Change-Id: Ib73fb9607438c7da115406f61653641163370122 Reviewed-by: MÃ¥rten Nordheim --- src/network/access/qnetworkcookiejar.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/network/access/qnetworkcookiejar.cpp b/src/network/access/qnetworkcookiejar.cpp index 9d5bc64ad5..82746f91b1 100644 --- a/src/network/access/qnetworkcookiejar.cpp +++ b/src/network/access/qnetworkcookiejar.cpp @@ -305,13 +305,14 @@ bool QNetworkCookieJar::deleteCookie(const QNetworkCookie &cookie) */ bool QNetworkCookieJar::validateCookie(const QNetworkCookie &cookie, const QUrl &url) const { - QString domain = cookie.domain(); + const QString cookieDomain = cookie.domain(); + QStringView domain = cookieDomain; const QString host = url.host(); if (!isParentDomain(domain, host) && !isParentDomain(host, domain)) return false; // not accepted if (domain.startsWith(u'.')) - domain = domain.mid(1); + domain = domain.sliced(1); // We shouldn't reject if: // "[...] the domain-attribute is identical to the canonicalized request-host"