@@ -1513,31 +1513,31 @@ public static unsafe int IndexOf<T>(T[] array, T value, int startIndex, int coun
1513
1513
{
1514
1514
int result = SpanHelpers . IndexOfValueType (
1515
1515
ref Unsafe . Add ( ref Unsafe . As < T , byte > ( ref MemoryMarshal . GetArrayDataReference ( array ) ) , startIndex ) ,
1516
- Unsafe . As < T , byte > ( ref value ) ,
1516
+ Unsafe . BitCast < T , byte > ( value ) ,
1517
1517
count ) ;
1518
1518
return ( result >= 0 ? startIndex : 0 ) + result ;
1519
1519
}
1520
1520
else if ( sizeof ( T ) == sizeof ( short ) )
1521
1521
{
1522
1522
int result = SpanHelpers . IndexOfValueType (
1523
1523
ref Unsafe . Add ( ref Unsafe . As < T , short > ( ref MemoryMarshal . GetArrayDataReference ( array ) ) , startIndex ) ,
1524
- Unsafe . As < T , short > ( ref value ) ,
1524
+ Unsafe . BitCast < T , short > ( value ) ,
1525
1525
count ) ;
1526
1526
return ( result >= 0 ? startIndex : 0 ) + result ;
1527
1527
}
1528
1528
else if ( sizeof ( T ) == sizeof ( int ) )
1529
1529
{
1530
1530
int result = SpanHelpers . IndexOfValueType (
1531
1531
ref Unsafe . Add ( ref Unsafe . As < T , int > ( ref MemoryMarshal . GetArrayDataReference ( array ) ) , startIndex ) ,
1532
- Unsafe . As < T , int > ( ref value ) ,
1532
+ Unsafe . BitCast < T , int > ( value ) ,
1533
1533
count ) ;
1534
1534
return ( result >= 0 ? startIndex : 0 ) + result ;
1535
1535
}
1536
1536
else if ( sizeof ( T ) == sizeof ( long ) )
1537
1537
{
1538
1538
int result = SpanHelpers . IndexOfValueType (
1539
1539
ref Unsafe . Add ( ref Unsafe . As < T , long > ( ref MemoryMarshal . GetArrayDataReference ( array ) ) , startIndex ) ,
1540
- Unsafe . As < T , long > ( ref value ) ,
1540
+ Unsafe . BitCast < T , long > ( value ) ,
1541
1541
count ) ;
1542
1542
return ( result >= 0 ? startIndex : 0 ) + result ;
1543
1543
}
@@ -1758,7 +1758,7 @@ public static unsafe int LastIndexOf<T>(T[] array, T value, int startIndex, int
1758
1758
int endIndex = startIndex - count + 1 ;
1759
1759
int result = SpanHelpers . LastIndexOfValueType (
1760
1760
ref Unsafe . Add ( ref Unsafe . As < T , byte > ( ref MemoryMarshal . GetArrayDataReference ( array ) ) , endIndex ) ,
1761
- Unsafe . As < T , byte > ( ref value ) ,
1761
+ Unsafe . BitCast < T , byte > ( value ) ,
1762
1762
count ) ;
1763
1763
1764
1764
return ( result >= 0 ? endIndex : 0 ) + result ;
@@ -1768,7 +1768,7 @@ ref Unsafe.Add(ref Unsafe.As<T, byte>(ref MemoryMarshal.GetArrayDataReference(ar
1768
1768
int endIndex = startIndex - count + 1 ;
1769
1769
int result = SpanHelpers . LastIndexOfValueType (
1770
1770
ref Unsafe . Add ( ref Unsafe . As < T , short > ( ref MemoryMarshal . GetArrayDataReference ( array ) ) , endIndex ) ,
1771
- Unsafe . As < T , short > ( ref value ) ,
1771
+ Unsafe . BitCast < T , short > ( value ) ,
1772
1772
count ) ;
1773
1773
1774
1774
return ( result >= 0 ? endIndex : 0 ) + result ;
@@ -1778,7 +1778,7 @@ ref Unsafe.Add(ref Unsafe.As<T, short>(ref MemoryMarshal.GetArrayDataReference(a
1778
1778
int endIndex = startIndex - count + 1 ;
1779
1779
int result = SpanHelpers . LastIndexOfValueType (
1780
1780
ref Unsafe . Add ( ref Unsafe . As < T , int > ( ref MemoryMarshal . GetArrayDataReference ( array ) ) , endIndex ) ,
1781
- Unsafe . As < T , int > ( ref value ) ,
1781
+ Unsafe . BitCast < T , int > ( value ) ,
1782
1782
count ) ;
1783
1783
1784
1784
return ( result >= 0 ? endIndex : 0 ) + result ;
@@ -1788,7 +1788,7 @@ ref Unsafe.Add(ref Unsafe.As<T, int>(ref MemoryMarshal.GetArrayDataReference(arr
1788
1788
int endIndex = startIndex - count + 1 ;
1789
1789
int result = SpanHelpers . LastIndexOfValueType (
1790
1790
ref Unsafe . Add ( ref Unsafe . As < T , long > ( ref MemoryMarshal . GetArrayDataReference ( array ) ) , endIndex ) ,
1791
- Unsafe . As < T , long > ( ref value ) ,
1791
+ Unsafe . BitCast < T , long > ( value ) ,
1792
1792
count ) ;
1793
1793
1794
1794
return ( result >= 0 ? endIndex : 0 ) + result ;
0 commit comments