diff options
author | dotnet bot <dotnet-bot@dotnetfoundation.org> | 2017-12-02 03:37:44 +0300 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2017-12-02 03:37:44 +0300 |
commit | 85595cc75a6983da81ac5b3a705d6f7d79fa418d (patch) | |
tree | 967219de7ec6a38da6a645251b0e545ef1bf8980 /src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs | |
parent | f826d5678f9b7f8b5a04c9b8bbdc1d13bd779aa9 (diff) |
Improve throughput of String.Split(char / char[], ...) (#15322) (#5053)
* Improve throughput of String.Split(char / char[], ...)
Also reduces the amount of unsafe code used.
* Address PR feedback
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Diffstat (limited to 'src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs')
-rw-r--r-- | src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs b/src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs index a84903518..1c127b19d 100644 --- a/src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs +++ b/src/System.Private.CoreLib/shared/System/StringSpanHelpers.cs @@ -90,6 +90,19 @@ namespace System return -1; } + public static bool Contains(this ReadOnlySpan<char> source, char value) + { + for (int i = 0; i < source.Length; i++) + { + if (source[i] == value) + { + return true; + } + } + + return false; + } + public static ReadOnlySpan<char> Remove(this ReadOnlySpan<char> source, int startIndex, int count) { if (startIndex < 0) throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndex); |