diff --git a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/RabinKarp.cs b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/RabinKarp.cs index f7d561c5d51f5..7c5de9c1d0b88 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/RabinKarp.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/RabinKarp.cs @@ -103,7 +103,6 @@ private readonly int IndexOfAnyCore(ReadOnlySpan span) { Debug.Assert(typeof(TCaseSensitivity) != typeof(CaseInsensitiveUnicode)); Debug.Assert(span.Length <= MaxInputLength, "Teddy should have handled short inputs."); - Debug.Assert(_buckets is not null); ref char current = ref MemoryMarshal.GetReference(span); @@ -119,6 +118,7 @@ private readonly int IndexOfAnyCore(ReadOnlySpan span) hash = (hash << HashShiftPerElement) + TCaseSensitivity.TransformInput(Unsafe.Add(ref current, i)); } + Debug.Assert(_buckets is not null); ref string[]? bucketsRef = ref MemoryMarshal.GetArrayDataReference(_buckets); while (true) diff --git a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/StringSearchValuesHelper.cs b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/StringSearchValuesHelper.cs index 436b265253ef5..e4a2af274784b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/StringSearchValuesHelper.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/StringSearchValuesHelper.cs @@ -47,7 +47,7 @@ private static bool ScalarEquals(ref char matchStart, string c { for (int i = 0; i < candidate.Length; i++) { - if (TCaseSensitivity.TransformInput(candidate[i]) != Unsafe.Add(ref matchStart, i)) + if (TCaseSensitivity.TransformInput(Unsafe.Add(ref matchStart, i)) != candidate[i]) { return false; } diff --git a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/SingleStringSearchValuesThreeChars.cs b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/SingleStringSearchValuesThreeChars.cs index 8b9f0f3015311..827287ceaf909 100644 --- a/src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/SingleStringSearchValuesThreeChars.cs +++ b/src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/SingleStringSearchValuesThreeChars.cs @@ -207,8 +207,6 @@ private int IndexOf(ref char searchSpace, int searchSpaceLength) } ShortInput: - Debug.Assert(searchSpaceLength < Vector128.Count); - string value = _value; char valueHead = value.GetRawStringData();