Skip to content

Commit

Permalink
Provide fast generic comparer for bool values (#5076)
Browse files Browse the repository at this point in the history
* provide fast generic comparer for bool values

* formatting
  • Loading branch information
vasily-kirichenko authored and TIHan committed Jun 4, 2018
1 parent 5bfd9fc commit 0e851c6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/fsharp/FSharp.Core/prim-types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2162,6 +2162,7 @@ namespace Microsoft.FSharp.Core
let FloatComparer = MakeGenericComparer<float>()
let Float32Comparer = MakeGenericComparer<float32>()
let DecimalComparer = MakeGenericComparer<decimal>()
let BoolComparer = MakeGenericComparer<bool>()

/// Use a type-indexed table to ensure we only create a single FastStructuralComparison function
/// for each type
Expand Down Expand Up @@ -2199,6 +2200,7 @@ namespace Microsoft.FSharp.Core
| ty when ty.Equals(typeof<float32>) -> null
| ty when ty.Equals(typeof<decimal>) -> null
| ty when ty.Equals(typeof<string>) -> unboxPrim (box StringComparer)
| ty when ty.Equals(typeof<bool>) -> null
| _ -> MakeGenericComparer<'T>()

static let f : System.Collections.Generic.IComparer<'T> =
Expand All @@ -2218,6 +2220,7 @@ namespace Microsoft.FSharp.Core
| ty when ty.Equals(typeof<float32>) -> unboxPrim (box Float32Comparer)
| ty when ty.Equals(typeof<decimal>) -> unboxPrim (box DecimalComparer)
| ty when ty.Equals(typeof<string>) -> unboxPrim (box StringComparer)
| ty when ty.Equals(typeof<bool>) -> unboxPrim (box BoolComparer)
| _ ->
// Review: There are situations where we should be able
// to return System.Collections.Generic.Comparer<'T>.Default here.
Expand Down

0 comments on commit 0e851c6

Please sign in to comment.