summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-05-22 17:06:51 +0200
committerLars Knoll <lars.knoll@qt.io>2020-06-10 09:09:29 +0200
commit4ab3089a2cbcc3b0656a36e9c22ca2d72e150c7e (patch)
tree39c9ae1f5e9c8c3ff66ecb6712cf5e0702418c46
parent957b99968351282b1b7b9306cd546b30ba56ee0c (diff)
Port QUrl away from QStringRef
Task-number: QTBUG-84319 Change-Id: I6167599ac86f17d37fbb6ea90d302641969b0f72 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/corelib/io/qurl.cpp18
1 files changed, 9 insertions, 9 deletions
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);