From 08f1d6f3df4d85727e783e3393ef63694d357b83 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 9 Dec 2020 10:39:18 -0800 Subject: QUrl: update parseIp6 to use QStringView, as the comment requested Change-Id: I55083c2909f64a1f8868fffd164f2058f226fa61 Reviewed-by: David Faure Reviewed-by: Lars Knoll --- src/corelib/io/qurl.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/corelib/io') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index ba16be7424..67f549036c 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -1239,20 +1239,18 @@ static const QChar *parseIpFuture(QString &host, const QChar *begin, const QChar // ONLY the IPv6 address is parsed here, WITHOUT the brackets static const QChar *parseIp6(QString &host, const QChar *begin, const QChar *end, QUrl::ParsingMode mode) { - // ### Update to use QStringView once QStringView::indexOf and QStringView::lastIndexOf exists - QString decoded; + QStringView decoded(begin, end); + QString decodedBuffer; if (mode == QUrl::TolerantMode) { // this struct is kept in automatic storage because it's only 4 bytes const ushort decodeColon[] = { decode(':'), 0 }; - if (qt_urlRecode(decoded, QStringView{begin, end}, QUrl::ComponentFormattingOption::PrettyDecoded, decodeColon) == 0) - decoded = QString(begin, end-begin); - } else { - decoded = QString(begin, end-begin); + if (qt_urlRecode(decodedBuffer, decoded, QUrl::ComponentFormattingOption::PrettyDecoded, decodeColon)) + decoded = decodedBuffer; } - const QLatin1String zoneIdIdentifier("%25"); + const QStringView zoneIdIdentifier(u"%25"); QIPAddressUtils::IPv6Address address; - QString zoneId; + QStringView zoneId; const QChar *endBeforeZoneId = decoded.constEnd(); -- cgit v1.2.3