@@ -400,8 +400,7 @@ private ref Entry FindEntry<TComparer>(TKey key, out bool found, IEqualityCompar
400
400
{
401
401
if ( typeof ( TComparer ) == typeof ( DefaultComparer ) )
402
402
{
403
- // Change to EqualityComparer<T>.Default when Jit recognises intrinsic https://github.com/dotnet/coreclr/pull/14125
404
- if ( default ( TKey ) == null ? entry . key . Equals ( key ) : StructKeyEquals ( entry . key , key ) )
403
+ if ( EqualityComparer < TKey > . Default . Equals ( entry . key , key ) )
405
404
{
406
405
return ref entry ;
407
406
}
@@ -502,8 +501,7 @@ private bool TryInsert<TInsertionBehavior, TComparer>(TKey key, TValue value, IE
502
501
bool keysEqual = false ;
503
502
if ( typeof ( TComparer ) == typeof ( DefaultComparer ) )
504
503
{
505
- // Change to EqualityComparer<T>.Default when Jit recognises intrinsic https://github.com/dotnet/coreclr/pull/14125
506
- keysEqual = default ( TKey ) == null ? candidateEntry . key . Equals ( key ) : StructKeyEquals ( candidateEntry . key , key ) ;
504
+ keysEqual = EqualityComparer < TKey > . Default . Equals ( candidateEntry . key , key ) ;
507
505
}
508
506
else if ( typeof ( TComparer ) == typeof ( CustomComparer ) )
509
507
{
@@ -784,8 +782,7 @@ private ref Entry Remove<TComparer>(TKey key, out bool success, IEqualityCompare
784
782
bool keysEqual = false ;
785
783
if ( typeof ( TComparer ) == typeof ( DefaultComparer ) )
786
784
{
787
- // Change to EqualityComparer<T>.Default when Jit recognises intrinsic https://github.com/dotnet/coreclr/pull/14125
788
- keysEqual = default ( TKey ) == null ? entry . key . Equals ( key ) : StructKeyEquals ( entry . key , key ) ;
785
+ keysEqual = EqualityComparer < TKey > . Default . Equals ( entry . key , key ) ;
789
786
}
790
787
else if ( typeof ( TComparer ) == typeof ( CustomComparer ) )
791
788
{
@@ -838,69 +835,6 @@ public bool TryGetValue(TKey key, out TValue value)
838
835
839
836
public bool TryAdd ( TKey key , TValue value ) => TryInsert < RejectIfExisting > ( key , value ) ;
840
837
841
- // Replace with EqualityComparer<T>.Default when Jit recognises intrinsic https://github.com/dotnet/coreclr/pull/14125
842
- [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
843
- private bool StructKeyEquals ( TKey key0 , TKey key1 )
844
- {
845
- Debug . Assert ( default ( TKey ) != null ) ;
846
-
847
- // Specialize equality for each of the BCL ValueType primitives
848
- // cast via object to the type and use them directly
849
- // the Jit will elide the boxing.
850
- if ( typeof ( TKey ) == typeof ( byte ) )
851
- {
852
- return ( byte ) ( object ) key0 == ( byte ) ( object ) key1 ;
853
- }
854
- else if ( typeof ( TKey ) == typeof ( sbyte ) )
855
- {
856
- return ( sbyte ) ( object ) key0 == ( sbyte ) ( object ) key1 ;
857
- }
858
- else if ( typeof ( TKey ) == typeof ( ushort ) )
859
- {
860
- return ( ushort ) ( object ) key0 == ( ushort ) ( object ) key1 ;
861
- }
862
- else if ( typeof ( TKey ) == typeof ( short ) )
863
- {
864
- return ( short ) ( object ) key0 == ( short ) ( object ) key1 ;
865
- }
866
- else if ( typeof ( TKey ) == typeof ( char ) )
867
- {
868
- return ( char ) ( object ) key0 == ( char ) ( object ) key1 ;
869
- }
870
- else if ( typeof ( TKey ) == typeof ( uint ) )
871
- {
872
- return ( uint ) ( object ) key0 == ( uint ) ( object ) key1 ;
873
- }
874
- else if ( typeof ( TKey ) == typeof ( int ) )
875
- {
876
- return ( int ) ( object ) key0 == ( int ) ( object ) key1 ;
877
- }
878
- else if ( typeof ( TKey ) == typeof ( ulong ) )
879
- {
880
- return ( ulong ) ( object ) key0 == ( ulong ) ( object ) key1 ;
881
- }
882
- else if ( typeof ( TKey ) == typeof ( long ) )
883
- {
884
- return ( long ) ( object ) key0 == ( long ) ( object ) key1 ;
885
- }
886
- else if ( typeof ( TKey ) == typeof ( IntPtr ) )
887
- {
888
- return ( IntPtr ) ( object ) key0 == ( IntPtr ) ( object ) key1 ;
889
- }
890
- else if ( typeof ( TKey ) == typeof ( UIntPtr ) )
891
- {
892
- return ( UIntPtr ) ( object ) key0 == ( UIntPtr ) ( object ) key1 ;
893
- }
894
- else if ( typeof ( TKey ) == typeof ( Guid ) )
895
- {
896
- return ( Guid ) ( object ) key0 == ( Guid ) ( object ) key1 ;
897
- }
898
- else
899
- {
900
- return EqualityComparer < TKey > . Default . Equals ( key0 , key1 ) ;
901
- }
902
- }
903
-
904
838
bool ICollection < KeyValuePair < TKey , TValue > > . IsReadOnly => false ;
905
839
906
840
void ICollection < KeyValuePair < TKey , TValue > > . CopyTo ( KeyValuePair < TKey , TValue > [ ] array , int index ) => CopyTo ( array , index ) ;
0 commit comments