Skip to content

Commit dbbc022

Browse files
N5N3tkf
andcommitted
Remove _extrema_rf optimization for AbstractFloat (follow advise)
Add TODO Co-Authored-By: Takafumi Arakaki <29282+tkf@users.noreply.github.com>
1 parent e72c1e8 commit dbbc022

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-19
lines changed

base/mpfr.jl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -706,17 +706,6 @@ function min(x::BigFloat, y::BigFloat)
706706
return z
707707
end
708708

709-
# We don't want allocations during `extrema`.
710-
# TODO: avoid allocations in `min/max`
711-
function Base._extrema_rf(x::NTuple{2,BigFloat}, y::NTuple{2,BigFloat})
712-
(x1, x2), (y1, y2) = x, y
713-
isnan(x1) && return x
714-
isnan(y1) && return y
715-
z1 = x1 < y1 || signbit(x1) > signbit(y1) ? x1 : y1
716-
z2 = x2 < y2 || signbit(x2) > signbit(y2) ? y2 : x2
717-
z1, z2
718-
end
719-
720709
function modf(x::BigFloat)
721710
zint = BigFloat()
722711
zfloat = BigFloat()

base/reduce.jl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -855,15 +855,8 @@ end
855855
ExtremaMap(::Type{T}) where {T} = ExtremaMap{Type{T}}(T)
856856
@inline (f::ExtremaMap)(x) = (y = f.f(x); (y, y))
857857

858+
# TODO: optimize for inputs <: AbstractFloat
858859
@inline _extrema_rf((min1, max1), (min2, max2)) = (min(min1, min2), max(max1, max2))
859-
# optimization for AbstractFloat
860-
function _extrema_rf(x::NTuple{2,T}, y::NTuple{2,T}) where {T<:AbstractFloat}
861-
(x1, x2), (y1, y2) = x, y
862-
anynan = isnan(x1)|isnan(y1)
863-
z1 = ifelse(anynan, x1-y1, ifelse(signbit(x1-y1), x1, y1))
864-
z2 = ifelse(anynan, x1-y1, ifelse(signbit(x2-y2), y2, x2))
865-
z1, z2
866-
end
867860

868861
## findmax, findmin, argmax & argmin
869862

0 commit comments

Comments
 (0)