Skip to content

Commit dc157d3

Browse files
committed
Update isgreater from review
- Explicitly cache `x == x` to save the compiler some work. - Rename _is_unorderable to !_is_reflexive.
1 parent 6bf15ed commit dc157d3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

base/operators.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,10 @@ smallest.
172172
# Implementation
173173
Types should not usually implement this function. Instead, implement `isless`.
174174
"""
175-
isgreater(a, b) = _is_unorderable(a) || _is_unorderable(b) ? isless(a, b) : isless(b, a)
176-
_is_unorderable(x) = !isa(x == x, Bool) || x != x
175+
isgreater(x, y) = _is_reflexive(x) && _is_reflexive(y) ? isless(y, x) : isless(x, y)
176+
_is_reflexive(x) = let eq = x == x
177+
isa(eq, Bool) && eq
178+
end
177179

178180

179181

0 commit comments

Comments
 (0)