From 4ab3089a2cbcc3b0656a36e9c22ca2d72e150c7e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 22 May 2020 17:06:51 +0200 Subject: Port QUrl away from QStringRef Task-number: QTBUG-84319 Change-Id: I6167599ac86f17d37fbb6ea90d302641969b0f72 Reviewed-by: Thiago Macieira Reviewed-by: Volker Hilsheimer --- src/corelib/io/qurl.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 608aaf6b11..db70fa86be 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -925,20 +925,20 @@ inline void QUrlPrivate::appendPath(QString &appendTo, QUrl::FormattingOptions o thePath = qt_normalizePathSegments(path, isLocalFile() ? QDirPrivate::DefaultNormalization : QDirPrivate::RemotePath); } - QStringRef thePathRef(&thePath); + QStringView thePathView(thePath); if (options & QUrl::RemoveFilename) { const int slash = path.lastIndexOf(QLatin1Char('/')); if (slash == -1) return; - thePathRef = path.leftRef(slash + 1); + thePathView = QStringView{path}.left(slash + 1); } // check if we need to remove trailing slashes if (options & QUrl::StripTrailingSlash) { - while (thePathRef.length() > 1 && thePathRef.endsWith(QLatin1Char('/'))) - thePathRef.chop(1); + while (thePathView.length() > 1 && thePathView.endsWith(QLatin1Char('/'))) + thePathView.chop(1); } - appendToUser(appendTo, thePathRef, options, + appendToUser(appendTo, thePathView, options, appendingTo == FullUrl || options & QUrl::EncodeDelimiters ? pathInUrl : pathInIsolation); } @@ -1527,7 +1527,7 @@ inline QString QUrlPrivate::mergePaths(const QString &relativePath) const if (!path.contains(QLatin1Char('/'))) newPath = relativePath; else - newPath = path.leftRef(path.lastIndexOf(QLatin1Char('/')) + 1) + relativePath; + newPath = QStringView{path}.left(path.lastIndexOf(QLatin1Char('/')) + 1) + relativePath; return newPath; } @@ -3813,7 +3813,7 @@ QUrl QUrl::fromLocalFile(const QString &localFile) } else if (deslashified.startsWith(QLatin1String("//"))) { // magic for shared drive on windows int indexOfPath = deslashified.indexOf(QLatin1Char('/'), 2); - QStringRef hostSpec = deslashified.midRef(2, indexOfPath - 2); + QStringView hostSpec = QStringView{deslashified}.mid(2, indexOfPath - 2); // Check for Windows-specific WebDAV specification: "//host@SSL/path". if (hostSpec.endsWith(webDavSslTag(), Qt::CaseInsensitive)) { hostSpec.truncate(hostSpec.size() - 4); @@ -4138,7 +4138,7 @@ static QUrl adjustFtpPath(QUrl url) if (url.scheme() == ftpScheme()) { QString path = url.path(QUrl::PrettyDecoded); if (path.startsWith(QLatin1String("//"))) - url.setPath(QLatin1String("/%2F") + path.midRef(2), QUrl::TolerantMode); + url.setPath(QLatin1String("/%2F") + QStringView{path}.mid(2), QUrl::TolerantMode); } return url; } @@ -4262,7 +4262,7 @@ QUrl QUrl::fromUserInput(const QString &userInput) if (urlPrepended.isValid() && (!urlPrepended.host().isEmpty() || !urlPrepended.path().isEmpty())) { int dotIndex = trimmedString.indexOf(QLatin1Char('.')); - const QStringRef hostscheme = trimmedString.leftRef(dotIndex); + const QStringView hostscheme = QStringView{trimmedString}.left(dotIndex); if (hostscheme.compare(ftpScheme(), Qt::CaseInsensitive) == 0) urlPrepended.setScheme(ftpScheme()); return adjustFtpPath(urlPrepended); -- cgit v1.2.3