Skip to content

Commit

Permalink
Update isgreater from review
Browse files Browse the repository at this point in the history
- Explicitly cache `x == x` to save the compiler some work.
- Rename _is_unorderable to !_is_reflexive.
  • Loading branch information
cmcaine committed Nov 21, 2020
1 parent 4a9c5fb commit e4ac3bb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ smallest.
# Implementation
Types should not usually implement this function. Instead, implement `isless`.
"""
isgreater(a, b) = _is_unorderable(a) || _is_unorderable(b) ? isless(a, b) : isless(b, a)
_is_unorderable(x) = !isa(x == x, Bool) || x != x
isgreater(x, y) = _is_reflexive(x) && _is_reflexive(y) ? isless(y, x) : isless(x, y)
_is_reflexive(x) = let eq = x == x
isa(eq, Bool) && eq
end



Expand Down

0 comments on commit e4ac3bb

Please sign in to comment.