Skip to content

Commit 2b0ba5f

Browse files
committed
Fix debug asserts
1 parent 70ff070 commit 2b0ba5f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/libraries/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/StringSearchValuesHelper.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public static bool Equals<TValueLength>(ref char matchStart, ref readonly Single
347347
// See comments on SingleStringSearchValuesPackedThreeChars.CanSkipAnchorMatchVerification.
348348
// When running on Arm64, this helper is also used to confirm vectorized anchor matches.
349349
// We do so because we're using UnzipEven when packing inputs, which may produce false positive anchor matches.
350-
Debug.Assert((matchStart & 0xFF) == state.Value[0]);
350+
Debug.Assert(TransformInput((char)(matchStart & 0xFF)) == state.Value[0]);
351351

352352
uint differentBits = (Unsafe.ReadUnaligned<uint>(ref matchByteStart) & CaseMask) - state.Value32_0;
353353
differentBits |= (Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref matchByteStart, state.SecondReadByteOffset)) & CaseMask) - state.Value32_1;
@@ -359,7 +359,7 @@ public static bool Equals<TValueLength>(ref char matchStart, ref readonly Single
359359
// It's only used as part of the scalar search loop, which always checks that the first character matches before calling this helper.
360360
// We know that the candidate is 2 or 3 characters long, and that the first character has already been checked.
361361
// We only have to to check whether the last 2 characters also match.
362-
Debug.Assert(matchStart == state.Value[0], "This should only be called after the first character has been checked");
362+
Debug.Assert(TransformInput(matchStart) == state.Value[0], "This should only be called after the first character has been checked");
363363

364364
return (Unsafe.ReadUnaligned<uint>(ref Unsafe.Add(ref matchByteStart, state.SecondReadByteOffset)) & CaseMask) == state.Value32_1;
365365
}
@@ -429,7 +429,6 @@ public static bool Equals<TValueLength>(ref char matchStart, ref readonly Single
429429
else
430430
{
431431
Debug.Assert(state.Value.Length is 2 or 3);
432-
Debug.Assert((matchStart & ~0x20) == (state.Value[0] & ~0x20));
433432

434433
ref byte matchByteStart = ref Unsafe.As<char, byte>(ref matchStart);
435434
uint differentBits = (Unsafe.ReadUnaligned<uint>(ref matchByteStart) & state.ToUpperMask32_0) - state.Value32_0;

0 commit comments

Comments
 (0)