Skip to content

Commit 81dcf6f

Browse files
committed
Refactor: Simplify NormalizePath logic and remove unused return value
1 parent 3499030 commit 81dcf6f

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

src/PetroglyphTools/PG.StarWarsGame.Engine.FileSystem/IO/PetroglyphFileSystem.Normalize.cs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,20 @@ public sealed partial class PetroglyphFileSystem
1212
{
1313
internal void NormalizePath(ref ValueStringBuilder stringBuilder)
1414
{
15-
stringBuilder.Length = NormalizePath(stringBuilder.RawChars.Slice(0, stringBuilder.Length));
15+
NormalizePath(stringBuilder.RawChars.Slice(0, stringBuilder.Length));
1616
}
1717

1818
// TODO: Check whether we can eliminate the double slash normalization
1919
// once we migrated to PGFileSystem
20-
private static int NormalizePath(Span<char> path)
20+
private static void NormalizePath(Span<char> path)
2121
{
2222
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
23-
return path.Length;
24-
25-
var writePos = 0;
26-
var lastWasSeparator = false;
23+
return;
2724
for (var i = 0; i < path.Length; i++)
2825
{
2926
var c = path[i];
30-
var isSeparator = c is '\\' or '/';
31-
if (isSeparator && lastWasSeparator)
32-
continue;
33-
path[writePos++] = isSeparator ? '/' : c;
34-
lastWasSeparator = isSeparator;
27+
if (IsDirectorySeparator(c))
28+
path[i] = '/';
3529
}
36-
37-
return writePos;
3830
}
3931
}

0 commit comments

Comments
 (0)