diff options
author | Ben Adams <thundercat@illyriad.co.uk> | 2019-01-16 19:31:56 +0100 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2019-01-16 10:31:56 -0800 |
commit | 4a57565f1accd0e7cafaf27a39ab2b29c41dcf07 (patch) | |
tree | 3fb0c2b86b7adcfb6b681afdafac6236763a60a3 | |
parent | e466b70bfb6c6763bef1300706122f10519882bf (diff) | |
download | coreclr-4a57565f1accd0e7cafaf27a39ab2b29c41dcf07.tar.gz coreclr-4a57565f1accd0e7cafaf27a39ab2b29c41dcf07.tar.bz2 coreclr-4a57565f1accd0e7cafaf27a39ab2b29c41dcf07.zip |
Reduce steps for string.Contains(string value) (#22008)
-rw-r--r-- | src/System.Private.CoreLib/shared/System/String.Searching.cs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/System.Private.CoreLib/shared/System/String.Searching.cs b/src/System.Private.CoreLib/shared/System/String.Searching.cs index 893c2c7448..cce119b1d0 100644 --- a/src/System.Private.CoreLib/shared/System/String.Searching.cs +++ b/src/System.Private.CoreLib/shared/System/String.Searching.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Globalization; -using System.Numerics; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Internal.Runtime.CompilerServices; @@ -14,7 +12,14 @@ namespace System { public bool Contains(string value) { - return (IndexOf(value, StringComparison.Ordinal) >= 0); + if (value == null) + ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value); + + return SpanHelpers.IndexOf( + ref _firstChar, + Length, + ref value._firstChar, + value.Length) >= 0; } public bool Contains(string value, StringComparison comparisonType) |