Skip to content

Commit ab13281

Browse files
committed
Similar treatment within prim-types for Comparer as dotnet#5112 was for EqualityComparer
1 parent 5b80e90 commit ab13281

File tree

4 files changed

+232
-143
lines changed

4 files changed

+232
-143
lines changed

src/fsharp/FSharp.Core/local.fs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ module internal Array =
991991
open System
992992

993993
let inline fastComparerForArraySort<'t when 't : comparison> () =
994-
LanguagePrimitives.FastGenericComparerCanBeNull<'t>
994+
LanguagePrimitives.FastGenericComparerInternal<'t>
995995

996996
// The input parameter should be checked by callers if necessary
997997
let inline zeroCreateUnchecked (count:int) =
@@ -1141,13 +1141,12 @@ module internal Array =
11411141
let len = array.Length
11421142
if len < 2 then ()
11431143
else
1144-
let cFast = LanguagePrimitives.FastGenericComparerCanBeNull<'T>
1145-
match cFast with
1146-
| null ->
1144+
let cFast = LanguagePrimitives.FastGenericComparerInternal<'T>
1145+
if obj.ReferenceEquals (cFast, System.Collections.Generic.Comparer<'T>.Default) then
11471146
// An optimization for the cases where the keys and values coincide and do not have identity, e.g. are integers
11481147
// In this case an unstable sort is just as good as a stable sort (and faster)
11491148
Array.Sort<_,_>(array, null)
1150-
| _ ->
1149+
else
11511150
// 'keys' is an array storing the projected keys
11521151
let keys = (array.Clone() :?> array<'T>)
11531152
stableSortWithKeys array keys

0 commit comments

Comments
 (0)