Skip to content

Commit

Permalink
Fixed the remove extension for Span<char>
Browse files Browse the repository at this point in the history
  • Loading branch information
Simnico99 committed Jan 31, 2023
1 parent f20c6bb commit 0a906f6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/ZirconNet.Core/Extensions/SpanCharExtension.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if NETCOREAPP3_1_OR_GREATER
namespace ZirconNet.Core.Extensions;
namespace ZirconNet.Core.Extensions;
public static class SpanCharExtension
{
public static Span<char> Remove(this Span<char> chars, char charToRemove)
Expand All @@ -14,10 +13,10 @@ public static Span<char> Remove(this Span<char> chars, char charToRemove)
continue;
}

span[++charPos] = character;
span[charPos++] = character;
}

return span.TrimEnd();
return span[..charPos];
}

public static Span<char> Remove(this Span<char> chars, char[] charsToRemove)
Expand All @@ -32,10 +31,9 @@ public static Span<char> Remove(this Span<char> chars, char[] charsToRemove)
continue;
}

span[++charPos] = character;
span[charPos++] = character;
}

return span.TrimEnd();
return span[..charPos];
}
}
#endif
}

0 comments on commit 0a906f6

Please sign in to comment.