From f0052af4914538e4ec327a12afa0500ffaddee49 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Thu, 19 Sep 2024 13:55:08 +0300 Subject: [PATCH] QDir: qt_normalizePathSegments: replace a while loop with an if 'out' is at the first dot, so we only need to backtrack to the first preceding slash, before removing the previous path segment. Change-Id: I2e0be0583d4e9e984305a52f50a51801461077ba Reviewed-by: Thiago Macieira --- src/corelib/io/qdir.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 4505d90c143..4825bb5e36c 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -2325,8 +2325,10 @@ bool qt_normalizePathSegments(QString *path, QDirPrivate::PathNormalizations fla continue; } } - while (out > start && *--out != u'/') - ; + + if (out > start) + --out; // backtrack the first dot + // backtrack the previous path segment while (out > start && out[-1] != u'/') --out; in += 2; // the two dots