Skip to content

Commit e4ac3bb

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 4a9c5fb commit e4ac3bb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

base/operators.jl

+4-2
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,10 @@ smallest.
183183
# Implementation
184184
Types should not usually implement this function. Instead, implement `isless`.
185185
"""
186-
isgreater(a, b) = _is_unorderable(a) || _is_unorderable(b) ? isless(a, b) : isless(b, a)
187-
_is_unorderable(x) = !isa(x == x, Bool) || x != x
186+
isgreater(x, y) = _is_reflexive(x) && _is_reflexive(y) ? isless(y, x) : isless(x, y)
187+
_is_reflexive(x) = let eq = x == x
188+
isa(eq, Bool) && eq
189+
end
188190

189191

190192

0 commit comments

Comments
 (0)