summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qurl.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2020-12-09 10:44:36 -0800
committerThiago Macieira <thiago.macieira@intel.com>2020-12-12 12:17:20 -0800
commit37917b94615ee448101a38ba9f589fd992716a63 (patch)
treec3044c0963bacb0c25fb077a794ec7aa60e55b32 /src/corelib/io/qurl.cpp
parent08f1d6f3df4d85727e783e3393ef63694d357b83 (diff)
QUrl: improve parseIp6's use of QStringView
Change-Id: I55083c2909f64a1f8868fffd164f20a2fb8ff7f6 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/io/qurl.cpp')
-rw-r--r--src/corelib/io/qurl.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 67f549036c..c303cfb13e 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -1252,12 +1252,10 @@ static const QChar *parseIp6(QString &host, const QChar *begin, const QChar *end
QIPAddressUtils::IPv6Address address;
QStringView zoneId;
- const QChar *endBeforeZoneId = decoded.constEnd();
-
int zoneIdPosition = decoded.indexOf(zoneIdIdentifier);
if ((zoneIdPosition != -1) && (decoded.lastIndexOf(zoneIdIdentifier) == zoneIdPosition)) {
zoneId = decoded.mid(zoneIdPosition + zoneIdIdentifier.size());
- endBeforeZoneId = decoded.constBegin() + zoneIdPosition;
+ decoded.truncate(zoneIdPosition);
// was there anything after the zone ID separator?
if (zoneId.isEmpty())
@@ -1266,14 +1264,14 @@ static const QChar *parseIp6(QString &host, const QChar *begin, const QChar *end
// did the address become empty after removing the zone ID?
// (it might have always been empty)
- if (decoded.constBegin() == endBeforeZoneId)
+ if (decoded.isEmpty())
return end;
- const QChar *ret = QIPAddressUtils::parseIp6(address, decoded.constBegin(), endBeforeZoneId);
+ const QChar *ret = QIPAddressUtils::parseIp6(address, decoded.constBegin(), decoded.constEnd());
if (ret)
return begin + (ret - decoded.constBegin());
- host.reserve(host.size() + (decoded.constEnd() - decoded.constBegin()));
+ host.reserve(host.size() + (end - begin) + 2); // +2 for the brackets
host += QLatin1Char('[');
QIPAddressUtils::toString(host, address);