From 0a906f648230f0ee0eb8fc1e242c3f28b48cb5fb Mon Sep 17 00:00:00 2001 From: Simnico99 Date: Tue, 31 Jan 2023 15:41:59 -0500 Subject: [PATCH] Fixed the remove extension for Span --- src/ZirconNet.Core/Extensions/SpanCharExtension.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/ZirconNet.Core/Extensions/SpanCharExtension.cs b/src/ZirconNet.Core/Extensions/SpanCharExtension.cs index 5cb930c..95ea3fc 100644 --- a/src/ZirconNet.Core/Extensions/SpanCharExtension.cs +++ b/src/ZirconNet.Core/Extensions/SpanCharExtension.cs @@ -1,5 +1,4 @@ -#if NETCOREAPP3_1_OR_GREATER -namespace ZirconNet.Core.Extensions; +namespace ZirconNet.Core.Extensions; public static class SpanCharExtension { public static Span Remove(this Span chars, char charToRemove) @@ -14,10 +13,10 @@ public static Span Remove(this Span chars, char charToRemove) continue; } - span[++charPos] = character; + span[charPos++] = character; } - return span.TrimEnd(); + return span[..charPos]; } public static Span Remove(this Span chars, char[] charsToRemove) @@ -32,10 +31,9 @@ public static Span Remove(this Span chars, char[] charsToRemove) continue; } - span[++charPos] = character; + span[charPos++] = character; } - return span.TrimEnd(); + return span[..charPos]; } -} -#endif \ No newline at end of file +} \ No newline at end of file