Remove null-terminator that was actually useless

This commit is contained in:
Exter-N 2023-06-21 00:41:41 +02:00 committed by Ottermandias
parent 22cb33e49e
commit f88b5761ba

View file

@ -43,14 +43,13 @@ internal record class ResolveContext(Configuration Config, IObjectIdentifier Ide
if (gamePath[lastDirectorySeparator + 1] != (byte)'-' || gamePath[lastDirectorySeparator + 2] != (byte)'-') if (gamePath[lastDirectorySeparator + 1] != (byte)'-' || gamePath[lastDirectorySeparator + 2] != (byte)'-')
{ {
Span<byte> prefixed = stackalloc byte[gamePath.Length + 3]; Span<byte> prefixed = stackalloc byte[gamePath.Length + 2];
gamePath.Span[..(lastDirectorySeparator + 1)].CopyTo(prefixed); gamePath.Span[..(lastDirectorySeparator + 1)].CopyTo(prefixed);
prefixed[lastDirectorySeparator + 1] = (byte)'-'; prefixed[lastDirectorySeparator + 1] = (byte)'-';
prefixed[lastDirectorySeparator + 2] = (byte)'-'; prefixed[lastDirectorySeparator + 2] = (byte)'-';
gamePath.Span[(lastDirectorySeparator + 1)..].CopyTo(prefixed[(lastDirectorySeparator + 3)..]); gamePath.Span[(lastDirectorySeparator + 1)..].CopyTo(prefixed[(lastDirectorySeparator + 3)..]);
prefixed[^1] = 0;
if (!Utf8GamePath.FromSpan(prefixed[..^1], out var tmp)) if (!Utf8GamePath.FromSpan(prefixed, out var tmp))
return null; return null;
gamePath = tmp.Path.Clone(); gamePath = tmp.Path.Clone();