diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2020-05-11 14:02:17 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2020-05-12 23:04:42 +0200 |
commit | 548dcef08976649c820054f3db1ad108c72439cd (patch) | |
tree | a2d9a199fcedf3c0aff3e0bf61ee23ed73aa4f3d /src/corelib/io/qurl.cpp | |
parent | cf52a36994db45d6eba72e9c17c641abd8d789a3 (diff) |
Port qt_urlRecode() to QStringView
It's about time :)
Change-Id: I27e597516318382850d4c193fd5b66a35fb9c316
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/io/qurl.cpp')
-rw-r--r-- | src/corelib/io/qurl.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 308d993440..608aaf6b11 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -825,7 +825,7 @@ recodeFromUser(const QString &input, const ushort *actions, int from, int to) QString output; const QChar *begin = input.constData() + from; const QChar *end = input.constData() + to; - if (qt_urlRecode(output, begin, end, {}, actions)) + if (qt_urlRecode(output, QStringView{begin, end}, {}, actions)) return output; return input.mid(from, to - from); @@ -833,7 +833,7 @@ recodeFromUser(const QString &input, const ushort *actions, int from, int to) // appendXXXX functions: copy from the internal form to the external, user form. // the internal value is stored in its PrettyDecoded form, so that case is easy. -static inline void appendToUser(QString &appendTo, const QStringRef &value, QUrl::FormattingOptions options, +static inline void appendToUser(QString &appendTo, QStringView value, QUrl::FormattingOptions options, const ushort *actions) { if (options == QUrl::PrettyDecoded) { @@ -841,17 +841,10 @@ static inline void appendToUser(QString &appendTo, const QStringRef &value, QUrl return; } - if (!qt_urlRecode(appendTo, value.data(), value.end(), options, actions)) + if (!qt_urlRecode(appendTo, value, options, actions)) appendTo += value; } -static inline void appendToUser(QString &appendTo, const QString &value, QUrl::FormattingOptions options, - const ushort *actions) -{ - appendToUser(appendTo, QStringRef(&value), options, actions); -} - - inline void QUrlPrivate::appendAuthority(QString &appendTo, QUrl::FormattingOptions options, Section appendingTo) const { if ((options & QUrl::RemoveUserInfo) != QUrl::RemoveUserInfo) { @@ -900,13 +893,13 @@ inline void QUrlPrivate::appendUserInfo(QString &appendTo, QUrl::FormattingOptio } } - if (!qt_urlRecode(appendTo, userName.constData(), userName.constEnd(), options, userNameActions)) + if (!qt_urlRecode(appendTo, userName, options, userNameActions)) appendTo += userName; if (options & QUrl::RemovePassword || !hasPassword()) { return; } else { appendTo += QLatin1Char(':'); - if (!qt_urlRecode(appendTo, password.constData(), password.constEnd(), options, passwordActions)) + if (!qt_urlRecode(appendTo, password, options, passwordActions)) appendTo += password; } } @@ -1178,7 +1171,7 @@ inline void QUrlPrivate::appendHost(QString &appendTo, QUrl::FormattingOptions o if (host.at(0).unicode() == '[') { // IPv6 addresses might contain a zone-id which needs to be recoded if (options != 0) - if (qt_urlRecode(appendTo, host.constBegin(), host.constEnd(), options, nullptr)) + if (qt_urlRecode(appendTo, host, options, nullptr)) return; appendTo += host; } else { @@ -1220,7 +1213,7 @@ static const QChar *parseIpFuture(QString &host, const QChar *begin, const QChar --end; QString decoded; - if (mode == QUrl::TolerantMode && qt_urlRecode(decoded, begin, end, QUrl::FullyDecoded, nullptr)) { + if (mode == QUrl::TolerantMode && qt_urlRecode(decoded, QStringView{begin, end}, QUrl::FullyDecoded, nullptr)) { begin = decoded.constBegin(); end = decoded.constEnd(); } @@ -1251,7 +1244,7 @@ static const QChar *parseIp6(QString &host, const QChar *begin, const QChar *end 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, begin, end, QUrl::ComponentFormattingOption::PrettyDecoded, decodeColon) == 0) + if (qt_urlRecode(decoded, QStringView{begin, end}, QUrl::ComponentFormattingOption::PrettyDecoded, decodeColon) == 0) decoded = QString(begin, end-begin); } else { decoded = QString(begin, end-begin); @@ -1351,7 +1344,7 @@ inline bool QUrlPrivate::setHost(const QString &value, int from, int iend, QUrl: // check for percent-encoding first QString s; - if (mode == QUrl::TolerantMode && qt_urlRecode(s, begin, end, { }, nullptr)) { + if (mode == QUrl::TolerantMode && qt_urlRecode(s, QStringView{begin, end}, { }, nullptr)) { // something was decoded // anything encoded left? int pos = s.indexOf(QChar(0x25)); // '%' |