{
Debug.Assert(length >= 0);
- IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
+ nint index = 0; // Use nint for arithmetic to avoid unnecessary 64->32->64 truncations
if (default(T) != null || (object)value != null)
{
}
else
{
- byte* len = (byte*)length;
- for (index = (IntPtr)0; index.ToPointer() < len; index += 1)
+ nint len = length;
+ for (index = 0; index < len; index++)
{
if ((object)Unsafe.Add(ref searchSpace, index) is null)
{
{
Debug.Assert(length >= 0);
- IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
+ nint index = 0; // Use nint for arithmetic to avoid unnecessary 64->32->64 truncations
if (default(T) != null || (object)value != null)
{
while (length >= 8)
}
else
{
- byte* len = (byte*)length;
- for (index = (IntPtr)0; index.ToPointer() < len; index += 1)
+ nint len = (nint)length;
+ for (index = 0; index < len; index++)
{
if ((object)Unsafe.Add(ref searchSpace, index) is null)
{
return -1;
Found: // Workaround for https://github.com/dotnet/runtime/issues/8795
- return (int)(byte*)index;
+ return (int)index;
Found1:
- return (int)(byte*)(index + 1);
+ return (int)(index + 1);
Found2:
- return (int)(byte*)(index + 2);
+ return (int)(index + 2);
Found3:
- return (int)(byte*)(index + 3);
+ return (int)(index + 3);
Found4:
- return (int)(byte*)(index + 4);
+ return (int)(index + 4);
Found5:
- return (int)(byte*)(index + 5);
+ return (int)(index + 5);
Found6:
- return (int)(byte*)(index + 6);
+ return (int)(index + 6);
Found7:
- return (int)(byte*)(index + 7);
+ return (int)(index + 7);
}
public static int IndexOfAny<T>(ref T searchSpace, T value0, T value1, int length) where T : IEquatable<T>
if (Unsafe.AreSame(ref first, ref second))
goto Equal;
- IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
+ nint index = 0; // Use nint for arithmetic to avoid unnecessary 64->32->64 truncations
T lookUp0;
T lookUp1;
while (length >= 8)