Skip to content

Commit

Permalink
make == type comparisions much cheaper and faster
Browse files Browse the repository at this point in the history
ref #11425
  • Loading branch information
vtjnash committed Apr 5, 2016
1 parent aa594a6 commit 18d1696
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ isless(x::AbstractFloat, y::AbstractFloat) = (!isnan(x) & isnan(y)) | (signbit(x
isless(x::Real, y::AbstractFloat) = (!isnan(x) & isnan(y)) | (signbit(x) & !signbit(y)) | (x < y)
isless(x::AbstractFloat, y::Real ) = (!isnan(x) & isnan(y)) | (signbit(x) & !signbit(y)) | (x < y)

=={T}(::Type{T}, ::Type{T}) = true # encourage more specialization on types (see #11425)
==(T::Type, S::Type) = typeseq(T, S)
function ==(T::Type, S::Type)
@_pure_meta
typeseq(T, S)
end
function !==(T::Type, S::Type)

This comment has been minimized.

Copy link
@JeffBezanson

JeffBezanson Apr 5, 2016

Member

Did you mean to define != instead?

This comment has been minimized.

Copy link
@vtjnash

vtjnash Apr 5, 2016

Author Member

yeah. eventually i just need to get inference to propagate pure across these trivial calls so that i could just mark subtype and then the rest of these would have been automatically inferred.

This comment has been minimized.

Copy link
@JeffBezanson

JeffBezanson Apr 5, 2016

Member

Ah. If we're going to keep this definition it should call === below, otherwise it doesn't do the right thing.

@_pure_meta
!(T == S)
end

## comparison fallbacks ##

Expand Down

0 comments on commit 18d1696

Please sign in to comment.