Skip to content

Commit 0aba774

Browse files
committed
Core.ifelse to avoid invalidations
1 parent ee37ef9 commit 0aba774

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

base/operators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ julia> max(2, 5, 1)
464464
5
465465
```
466466
"""
467-
max(x, y) = ifelse(isless(y, x), x, y)
467+
max(x, y) = Core.ifelse(isless(y, x), x, y)
468468

469469
"""
470470
min(x, y, ...)

base/reduce.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,15 +616,15 @@ prod(a; kw...) = mapreduce(identity, mul_prod, a; kw...)
616616
_fast(::typeof(min),x,y) = min(x,y)
617617
_fast(::typeof(max),x,y) = max(x,y)
618618
function _fast(::typeof(max), x::AbstractFloat, y::AbstractFloat)
619-
ifelse(isnan(x),
619+
Core.ifelse(isnan(x),
620620
x,
621-
ifelse(x > y, x, y))
621+
Core.ifelse(x > y, x, y))
622622
end
623623

624624
function _fast(::typeof(min),x::AbstractFloat, y::AbstractFloat)
625-
ifelse(isnan(x),
625+
Core.ifelse(isnan(x),
626626
x,
627-
ifelse(x < y, x, y))
627+
Core.ifelse(x < y, x, y))
628628
end
629629

630630
isbadzero(::typeof(max), x::AbstractFloat) = (x == zero(x)) & signbit(x)
@@ -860,8 +860,8 @@ ExtremaMap(::Type{T}) where {T} = ExtremaMap{Type{T}}(T)
860860
function _extrema_rf(x::NTuple{2,T}, y::NTuple{2,T}) where {T<:IEEEFloat}
861861
(x1, x2), (y1, y2) = x, y
862862
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))
863+
z1 = Core.ifelse(anynan, x1-y1, Core.ifelse(signbit(x1-y1), x1, y1))
864+
z2 = Core.ifelse(anynan, x1-y1, Core.ifelse(signbit(x2-y2), y2, x2))
865865
z1, z2
866866
end
867867

0 commit comments

Comments
 (0)