QUrl: update parseIp6 to use QStringView, as the comment requested

Change-Id: I55083c2909f64a1f8868fffd164f2058f226fa61
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Thiago Macieira 2020-12-09 10:39:18 -08:00
parent 4974091699
commit 08f1d6f3df

View File

@ -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 // 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) 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 QStringView decoded(begin, end);
QString decoded; QString decodedBuffer;
if (mode == QUrl::TolerantMode) { if (mode == QUrl::TolerantMode) {
// this struct is kept in automatic storage because it's only 4 bytes // this struct is kept in automatic storage because it's only 4 bytes
const ushort decodeColon[] = { decode(':'), 0 }; const ushort decodeColon[] = { decode(':'), 0 };
if (qt_urlRecode(decoded, QStringView{begin, end}, QUrl::ComponentFormattingOption::PrettyDecoded, decodeColon) == 0) if (qt_urlRecode(decodedBuffer, decoded, QUrl::ComponentFormattingOption::PrettyDecoded, decodeColon))
decoded = QString(begin, end-begin); decoded = decodedBuffer;
} else {
decoded = QString(begin, end-begin);
} }
const QLatin1String zoneIdIdentifier("%25"); const QStringView zoneIdIdentifier(u"%25");
QIPAddressUtils::IPv6Address address; QIPAddressUtils::IPv6Address address;
QString zoneId; QStringView zoneId;
const QChar *endBeforeZoneId = decoded.constEnd(); const QChar *endBeforeZoneId = decoded.constEnd();