Skip to content

Commit

Permalink
Removes unused helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Dandy committed Dec 3, 2023
1 parent 43b6cf1 commit d698646
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 45 deletions.
2 changes: 0 additions & 2 deletions WeCantSpell.Hunspell/Infrastructure/ArrayEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ static class ArrayEx

#endif

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool Any<T>(this T[] array) => array.Length != 0;
}
6 changes: 6 additions & 0 deletions WeCantSpell.Hunspell/Infrastructure/DictionaryEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace WeCantSpell.Hunspell.Infrastructure;

#if NO_DICTIONARY_GETVALUE || NO_KVP_DECONSTRUCT

static class DictionaryEx
{

#if NO_DICTIONARY_GETVALUE

public static TValue? GetValueOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key) =>
Expand All @@ -23,4 +26,7 @@ public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> pai
}

#endif

}

#endif
3 changes: 3 additions & 0 deletions WeCantSpell.Hunspell/Infrastructure/HunspellTextFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace WeCantSpell.Hunspell.Infrastructure;

static class HunspellTextFunctions
{

#if false // This isn't used anymore but I want to keep it around as it was tricky to port
public static bool IsReverseSubset(string s1, ReadOnlySpan<char> s2)
{
return s1.Length <= s2.Length && check(s1.AsSpan(), s2);
Expand All @@ -27,6 +29,7 @@ static bool check(ReadOnlySpan<char> s1, ReadOnlySpan<char> s2)
return true;
}
}
#endif

public static bool IsSubset(string s1, ReadOnlySpan<char> s2)
{
Expand Down
43 changes: 0 additions & 43 deletions WeCantSpell.Hunspell/Infrastructure/MemoryEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ namespace WeCantSpell.Hunspell.Infrastructure;

static class MemoryEx
{
#if NO_SPAN_CONTAINS

public static bool Contains<T>(this ReadOnlySpan<T> @this, T value) where T : IEquatable<T> => @this.IndexOf(value) >= 0;

public static bool Contains<T>(this Span<T> @this, T value) where T : IEquatable<T> => @this.IndexOf(value) >= 0;

#endif

public static int IndexOf<T>(this ReadOnlySpan<T> @this, T value, int startIndex) where T : IEquatable<T>
{
Expand Down Expand Up @@ -101,42 +94,6 @@ public static void Sort<T>(this Span<T> span, Comparison<T> comparer)
}
}

#endif

#if NO_SPAN_TRIM

public static ReadOnlySpan<T> TrimStart<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T>?
{
var start = 0;

if (value is null)
{
for (; start < span.Length && span[start] is not null; start++) ;
}
else
{
for (; start < span.Length && !value.Equals(span[start]); start++) ;
}

return span.Slice(start);
}

public static Span<T> TrimStart<T>(this Span<T> span, T value) where T : IEquatable<T>?
{
var start = 0;

if (value is null)
{
for (; start < span.Length && span[start] is null; start++) ;
}
else
{
for (; start < span.Length && value.Equals(span[start]); start++) ;
}

return span.Slice(start);
}

#endif

public static void RemoveAll<T>(ref Span<T> span, T value) where T : notnull, IEquatable<T>
Expand Down

0 comments on commit d698646

Please sign in to comment.