Skip to content

Commit 9177e69

Browse files
committed
Avoid LoopVectorization within @generated
1 parent 5ae822c commit 9177e69

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/Utils.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ end
7676
# Fastest way to check for NaN in an array.
7777
# Thanks @mikmore https://discourse.julialang.org/t/fastest-way-to-check-for-inf-or-nan-in-an-array/76954/33?u=milescranmer
7878
is_bad_array(x) = !is_good_array(x)
79-
@generated function is_good_array(x)
80-
Sys.iswindows() && return :(sum(xi -> xi * zero(xi), x) == zero(eltype(x)))
81-
return :(isempty(x) || vmapreduce(xi -> xi * zero(xi), +, x) == zero(eltype(x)))
79+
function is_good_array(x)
80+
IS_WINDOWS && return sum(xi -> xi * zero(xi), x) == zero(eltype(x))
81+
return isempty(x) || vmapreduce(xi -> xi * zero(xi), +, x) == zero(eltype(x))
8282
end
83+
const IS_WINDOWS = Sys.iswindows()
8384

8485
isgood(x::T) where {T<:Number} = !(isnan(x) || !isfinite(x))
8586
isgood(x) = true

0 commit comments

Comments
 (0)