Skip to content

Commit

Permalink
QUrl: update parseIp6 to use QStringView, as the comment requested
Browse files Browse the repository at this point in the history
Change-Id: I55083c2909f64a1f8868fffd164f2058f226fa61
Reviewed-by: David Faure <[email protected]>
Reviewed-by: Lars Knoll <[email protected]>
  • Loading branch information
thiagomacieira committed Dec 12, 2020
1 parent 4974091 commit 08f1d6f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/corelib/io/qurl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 08f1d6f

Please sign in to comment.