From 55b8143937f365cb18bb469120eb95529ced6178 Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Wed, 9 Oct 2024 15:18:36 -0400 Subject: [PATCH] Improve inferrability Co-authored-by: Gabriel Baraldi --- src/fft.jl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/fft.jl b/src/fft.jl index d58b121..4be9e51 100644 --- a/src/fft.jl +++ b/src/fft.jl @@ -319,9 +319,9 @@ unsafe_convert(::Type{PlanPtr}, p::FFTWPlan) = p.plan # This is accomplished by the maybe_destroy_plan function, which is used as the plan finalizer. # these functions should only be called while the fftwlock is held -unsafe_destroy_plan(plan::FFTWPlan{<:fftwDouble}) = +unsafe_destroy_plan(@nospecialize(plan::FFTWPlan{<:fftwDouble})) = ccall((:fftw_destroy_plan,libfftw3[]), Cvoid, (PlanPtr,), plan) -unsafe_destroy_plan(plan::FFTWPlan{<:fftwSingle}) = +unsafe_destroy_plan(@nospecialize(plan::FFTWPlan{<:fftwSingle})) = ccall((:fftwf_destroy_plan,libfftw3f[]), Cvoid, (PlanPtr,), plan) const deferred_destroy_lock = ReentrantLock() # lock protecting the deferred_destroy_plans list @@ -335,7 +335,12 @@ function destroy_deferred() # we'll do nothing (the other function will eventually run destroy_deferred). if !isempty(deferred_destroy_plans) && trylock(fftwlock) try - foreach(unsafe_destroy_plan, deferred_destroy_plans) + @static if Base.VERSION >= v"1.9" + @inline foreach(unsafe_destroy_plan, deferred_destroy_plans) + else + # call-site @inline isn't supported on old versions of Julia + foreach(unsafe_destroy_plan, deferred_destroy_plans) + end empty!(deferred_destroy_plans) finally unlock(fftwlock)