mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-21 16:08:48 +00:00
refactor: remove zombie Span.Replace
This commit is contained in:
parent
02ab7dce47
commit
51e7d00c48
@ -16,28 +16,6 @@ public static class SpanExtensions
|
||||
return source;
|
||||
}
|
||||
|
||||
#if !NET8_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Replaces all occurrences of a specified element in a span of elements with another specified element.
|
||||
/// </summary>
|
||||
/// <param name="haystack">The source span.</param>
|
||||
/// <param name="needle">The element to replace.</param>
|
||||
/// <param name="replacement">The replacement element.</param>
|
||||
/// <typeparam name="T">The type of elements in <paramref name="haystack" />.</typeparam>
|
||||
public static void Replace<T>(this Span<T> haystack, T needle, T replacement) where T : struct
|
||||
{
|
||||
var comparer = EqualityComparer<T>.Default;
|
||||
|
||||
for (var index = 0; index < haystack.Length; index++)
|
||||
{
|
||||
if (comparer.Equals(haystack[index], needle))
|
||||
{
|
||||
haystack[index] = replacement;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !NET9_0_OR_GREATER
|
||||
/// <summary>
|
||||
/// Splits a span of elements into sub-spans based on a delimiting element.
|
||||
|
Loading…
Reference in New Issue
Block a user