Skip to content

Commit cb39029

Browse files
committed
Remove unused methods
1 parent 40aa96c commit cb39029

File tree

2 files changed

+0
-168
lines changed

2 files changed

+0
-168
lines changed

Ramstack.Globbing.Tests/Traversal/PathHelperTests.cs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -154,45 +154,6 @@ public void GetPartialPattern_Generated()
154154
}
155155
}
156156

157-
[Test]
158-
public void SearchPathSeparator()
159-
{
160-
for (var n = 0; n < 5000; n++)
161-
{
162-
var p0 = new string('a', n);
163-
164-
var p1 = p0 + "\\";
165-
var index1 = PathHelper.SearchPathSeparator(p1, MatchFlags.Windows);
166-
var index2 = PathHelper.SearchPathSeparator(p1, MatchFlags.Unix);
167-
168-
Assert.That(index1, Is.EqualTo(p1.IndexOf('\\')), $"length: {n}");
169-
Assert.That(index2, Is.EqualTo(-1), $"length: {n}");
170-
171-
var p2 = p0 + "/";
172-
var index3 = PathHelper.SearchPathSeparator(p2, MatchFlags.Windows);
173-
var index4 = PathHelper.SearchPathSeparator(p2, MatchFlags.Unix);
174-
175-
Assert.That(index3, Is.EqualTo(p2.IndexOf('/')), $"length: {n}");
176-
Assert.That(index4, Is.EqualTo(index3), $"length: {n}");
177-
}
178-
}
179-
180-
[Test]
181-
public void SearchPathSeparator_Nothing()
182-
{
183-
var source = new string('a', 5000);
184-
185-
for (var n = 0; n < 5000; n++)
186-
{
187-
var p = source.AsSpan(0, n);
188-
var index1 = PathHelper.SearchPathSeparator(p, MatchFlags.Windows);
189-
var index2 = PathHelper.SearchPathSeparator(p, MatchFlags.Unix);
190-
191-
Assert.That(index1, Is.EqualTo(-1));
192-
Assert.That(index2, Is.EqualTo(-1));
193-
}
194-
}
195-
196157
private static IEnumerable<(string path, char slash, MatchFlags flags)> GeneratePaths()
197158
{
198159
var flags = new[]

Ramstack.Globbing/Traversal/PathHelper.cs

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -15,135 +15,6 @@ namespace Ramstack.Globbing.Traversal;
1515
[SuppressMessage("ReSharper", "RedundantCast")]
1616
internal static class PathHelper
1717
{
18-
/// <summary>
19-
/// Searches for a path separator within a span of characters.
20-
/// </summary>
21-
/// <param name="path">The span of characters representing the path.</param>
22-
/// <param name="flags">The flags indicating the type of path separators to match.</param>
23-
/// <returns>
24-
/// The index of the path separator if found; otherwise, <c>-1</c>.
25-
/// </returns>
26-
public static int SearchPathSeparator(scoped ReadOnlySpan<char> path, MatchFlags flags)
27-
{
28-
var count = (nint)(uint)path.Length;
29-
ref var p = ref MemoryMarshal.GetReference(path);
30-
return SearchPathSeparator(ref p, count, flags);
31-
}
32-
33-
/// <summary>
34-
/// Searches for a path separator within a range of characters.
35-
/// </summary>
36-
/// <param name="p">A reference to the first character of the range.</param>
37-
/// <param name="count">The number of characters to search through.</param>
38-
/// <param name="flags">The flags indicating the type of path separators to match.</param>
39-
/// <returns>
40-
/// The index of the path separator if found; otherwise, <c>-1</c>.
41-
/// </returns>
42-
public static int SearchPathSeparator(scoped ref char p, nint count, MatchFlags flags)
43-
{
44-
var index = (nint)0;
45-
46-
if (!Sse41.IsSupported || count < Vector128<ushort>.Count)
47-
{
48-
for (; index < count; index++)
49-
if (Unsafe.Add(ref p, index) == '/'
50-
|| (Unsafe.Add(ref p, index) == '\\' && flags == MatchFlags.Windows))
51-
return (int)index;
52-
53-
return -1;
54-
}
55-
56-
if (!Avx2.IsSupported || count < Vector256<ushort>.Count)
57-
{
58-
var slash = Vector128.Create((ushort)'/');
59-
var backslash = Vector128.Create((ushort)'\\');
60-
var allowEscaping = CreateAllowEscaping128Bitmask(flags);
61-
62-
var tail = count - Vector128<ushort>.Count;
63-
64-
Vector128<ushort> chunk;
65-
Vector128<ushort> comparison;
66-
67-
do
68-
{
69-
chunk = LoadVector128(ref p, index);
70-
comparison = Sse2.Or(
71-
Sse2.CompareEqual(chunk, slash),
72-
Sse2.AndNot(
73-
allowEscaping,
74-
Sse2.CompareEqual(chunk, backslash)));
75-
76-
if (!Sse41.TestZ(comparison, comparison))
77-
{
78-
var position = BitOperations.TrailingZeroCount(Sse2.MoveMask(comparison.AsByte()));
79-
return (int)index + (position >>> 1);
80-
}
81-
82-
index += Vector128<ushort>.Count;
83-
}
84-
while (index + Vector128<ushort>.Count <= count);
85-
86-
chunk = LoadVector128(ref p, tail);
87-
comparison = Sse2.Or(
88-
Sse2.CompareEqual(chunk, slash),
89-
Sse2.AndNot(
90-
allowEscaping,
91-
Sse2.CompareEqual(chunk, backslash)));
92-
93-
if (!Sse41.TestZ(comparison, comparison))
94-
{
95-
var position = BitOperations.TrailingZeroCount(Sse2.MoveMask(comparison.AsByte()));
96-
return (int)tail + (position >>> 1);
97-
}
98-
99-
return -1;
100-
}
101-
else
102-
{
103-
var slash = Vector256.Create((ushort)'/');
104-
var backslash = Vector256.Create((ushort)'\\');
105-
var allowEscaping = CreateAllowEscaping256Bitmask(flags);
106-
var tail = count - Vector256<ushort>.Count;
107-
108-
Vector256<ushort> chunk;
109-
Vector256<ushort> comparison;
110-
111-
do
112-
{
113-
chunk = LoadVector256(ref p, index);
114-
comparison = Avx2.Or(
115-
Avx2.CompareEqual(chunk, slash),
116-
Avx2.AndNot(
117-
allowEscaping,
118-
Avx2.CompareEqual(chunk, backslash)));
119-
120-
if (!Avx.TestZ(comparison, comparison))
121-
{
122-
var position = BitOperations.TrailingZeroCount(Avx2.MoveMask(comparison.AsByte()));
123-
return (int)index + (position >>> 1);
124-
}
125-
126-
index += Vector256<ushort>.Count;
127-
}
128-
while (index + Vector256<ushort>.Count <= count);
129-
130-
chunk = LoadVector256(ref p, tail);
131-
comparison = Avx2.Or(
132-
Avx2.CompareEqual(chunk, slash),
133-
Avx2.AndNot(
134-
allowEscaping,
135-
Avx2.CompareEqual(chunk, backslash)));
136-
137-
if (!Avx.TestZ(comparison, comparison))
138-
{
139-
var position = BitOperations.TrailingZeroCount(Avx2.MoveMask(comparison.AsByte()));
140-
return (int)tail + (position >>> 1);
141-
}
142-
143-
return -1;
144-
}
145-
}
146-
14718
/// <summary>
14819
/// Determines whether the specified path matches any of the specified patterns.
14920
/// </summary>

0 commit comments

Comments
 (0)