Skip to content

Commit

Permalink
Remove redundant definition of UIntType (#48157)
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner authored Jan 7, 2023
1 parent 98d5a0a commit 8dbf7a1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions base/sort.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Sort

using Base.Order

using Base: copymutable, midpoint, require_one_based_indexing,
using Base: copymutable, midpoint, require_one_based_indexing, uinttype,
sub_with_overflow, add_with_overflow, OneTo, BitSigned, BitIntegerType

import Base:
Expand Down Expand Up @@ -611,17 +611,14 @@ struct IEEEFloatOptimization{T <: Algorithm} <: Algorithm
next::T
end

UIntType(::Type{Float16}) = UInt16
UIntType(::Type{Float32}) = UInt32
UIntType(::Type{Float64}) = UInt64
after_zero(::ForwardOrdering, x) = !signbit(x)
after_zero(::ReverseOrdering, x) = signbit(x)
is_concrete_IEEEFloat(T::Type) = T <: Base.IEEEFloat && isconcretetype(T)
function _sort!(v::AbstractVector, a::IEEEFloatOptimization, o::Ordering, kw)
@getkw lo hi
if is_concrete_IEEEFloat(eltype(v)) && o isa DirectOrdering
lo, hi = send_to_end!(isnan, v, o, true; lo, hi)
iv = reinterpret(UIntType(eltype(v)), v)
iv = reinterpret(uinttype(eltype(v)), v)
j = send_to_end!(x -> after_zero(o, x), v; lo, hi)
scratch = _sort!(iv, a.next, Reverse, (;kw..., lo, hi=j))
if scratch === nothing # Union split
Expand All @@ -631,7 +628,7 @@ function _sort!(v::AbstractVector, a::IEEEFloatOptimization, o::Ordering, kw)
end
elseif eltype(v) <: Integer && o isa Perm && o.order isa DirectOrdering && is_concrete_IEEEFloat(eltype(o.data))
lo, hi = send_to_end!(i -> isnan(@inbounds o.data[i]), v, o.order, true; lo, hi)
ip = reinterpret(UIntType(eltype(o.data)), o.data)
ip = reinterpret(uinttype(eltype(o.data)), o.data)
j = send_to_end!(i -> after_zero(o.order, @inbounds o.data[i]), v; lo, hi)
scratch = _sort!(v, a.next, Perm(Reverse, ip), (;kw..., lo, hi=j))
if scratch === nothing # Union split
Expand Down

0 comments on commit 8dbf7a1

Please sign in to comment.