Skip to content

Commit

Permalink
QDir: qt_normalizePathSegments: replace a while loop with an if
Browse files Browse the repository at this point in the history
'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 <[email protected]>
  • Loading branch information
ahmadsamir committed Sep 20, 2024
1 parent 30f6f1a commit f0052af
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/corelib/io/qdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f0052af

Please sign in to comment.