QUrl::resolved: remove the lambda in removeDotsFromPath()
I had made this change but didn't push it. Amends commit 09055d7211b1f8ba9fdec141a1e919faee1c1676 Pick-to: 6.8.0 6.7 6.5 Change-Id: I8a96935cf6c742259c9dfffd17e8fc87d41dd891 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 01fbb883ad8832808110e74a0c4b2724f1e38d6c)
This commit is contained in:
parent
7b45dc49bb
commit
5eafba18e0
@ -1545,25 +1545,22 @@ static void removeDotsFromPath(QString *path)
|
||||
|
||||
// Scan the input for a "." or ".." segment. If there isn't any, then we
|
||||
// don't need to modify this path at all.
|
||||
qsizetype modidx = [&] {
|
||||
bool lastWasSlash = true;
|
||||
for (qsizetype i = 0, n = path->size(); i < n; ++i) {
|
||||
if (lastWasSlash && in[i] == u'.') {
|
||||
if (i + 1 == n || in[i + 1] == u'/')
|
||||
return i;
|
||||
if (in[i + 1] == u'.' && (i + 2 == n || in[i + 2] == u'/'))
|
||||
return i;
|
||||
}
|
||||
lastWasSlash = in[i] == u'/';
|
||||
qsizetype i = 0, n = path->size();
|
||||
for (bool lastWasSlash = true; i < n; ++i) {
|
||||
if (lastWasSlash && in[i] == u'.') {
|
||||
if (i + 1 == n || in[i + 1] == u'/')
|
||||
break;
|
||||
if (in[i + 1] == u'.' && (i + 2 == n || in[i + 2] == u'/'))
|
||||
break;
|
||||
}
|
||||
return qsizetype(-1);
|
||||
}();
|
||||
if (modidx < 0)
|
||||
lastWasSlash = in[i] == u'/';
|
||||
}
|
||||
if (i == n)
|
||||
return;
|
||||
|
||||
QChar *out = path->data();
|
||||
const QChar *end = out + path->size();
|
||||
out += modidx;
|
||||
out += i;
|
||||
in = out;
|
||||
|
||||
// We implement a modified algorithm compared to RFC 3986, for efficiency.
|
||||
|
Loading…
x
Reference in New Issue
Block a user