From 01fbb883ad8832808110e74a0c4b2724f1e38d6c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 5 Aug 2024 17:35:17 -0700 Subject: [PATCH] QUrl::resolved: remove the lambda in removeDotsFromPath() I had made this change but didn't push it. Amends commit 09055d7211b1f8ba9fdec141a1e919faee1c1676 Change-Id: I8a96935cf6c742259c9dfffd17e8fc87d41dd891 Reviewed-by: Ahmad Samir Reviewed-by: Edward Welbourne --- src/corelib/io/qurl.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 36cbed7be11..c67d8e9fbb6 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -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.