Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Ramstack.FileSystem.Globbing/Internal/PathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ public static ReadOnlySpan<char> GetPartialPattern(string pattern, int depth)
if (depth < 1
|| r.final == length
|| IsGlobStar(ref s, r.start, r.final))
{
Debug.Assert(r.final >= 0 && r.final <= pattern.Length);
return MemoryMarshal.CreateReadOnlySpan(ref s, r.final);
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down Expand Up @@ -246,7 +249,7 @@ public PathSegmentIterator() =>
return (start, _last);
}

if (Avx2.IsSupported && (int)_position + Vector256<ushort>.Count <= length)
if (Avx2.IsSupported && (int)_position <= length - Vector256<ushort>.Count)
{
var chunk = LoadVector256(ref source, _position);
var slash = Vector256.Create((ushort)'/');
Expand All @@ -266,7 +269,7 @@ public PathSegmentIterator() =>
if (_mask == 0)
_position += Vector256<ushort>.Count;
}
else if (Sse2.IsSupported && !Avx2.IsSupported && (int)_position + Vector128<ushort>.Count <= length)
else if (Sse2.IsSupported && !Avx2.IsSupported && (int)_position <= length - Vector128<ushort>.Count)
{
var chunk = LoadVector128(ref source, _position);
var slash = Vector128.Create((ushort)'/');
Expand All @@ -286,7 +289,7 @@ public PathSegmentIterator() =>
if (_mask == 0)
_position += Vector128<ushort>.Count;
}
else if (AdvSimd.Arm64.IsSupported && (int)_position + Vector128<ushort>.Count <= length)
else if (AdvSimd.Arm64.IsSupported && (int)_position <= length - Vector128<ushort>.Count)
{
var chunk = LoadVector128(ref source, _position);
var slash = Vector128.Create((ushort)'/');
Expand Down
Loading