@@ -160,7 +160,8 @@ function set_time!(o::TimeDependentSum, t::Number)
160160 o. current_time = t
161161 update_static_coefficients! (static_operator (o), coefficients (o), t)
162162 end
163- set_time! .(suboperators (o), t)
163+ # foreach is type-stable for tuples and concrete-typed vectors
164+ foreach (o -> set_time! (o, t), suboperators (o))
164165 o
165166end
166167
@@ -291,13 +292,15 @@ end
291292
292293@inline eval_coefficients (coeffs:: Tuple , t:: Number ) = map (c-> eval_coefficient (c, t), coeffs)
293294
294- # This is the performance-critical implementation.
295- # To avoid allocations in most cases, we model this on map(f, t::Tuple).
296- @inline eval_coefficients (:: Type{T} , coeffs:: Tuple{Any,} , t:: Number ) where T = (T (eval_coefficient (coeffs[1 ], t)),)
297- @inline eval_coefficients (:: Type{T} , coeffs:: Tuple{Any, Any} , t:: Number ) where T = (T (eval_coefficient (coeffs[1 ], t)), T (eval_coefficient (coeffs[2 ], t)))
298- @inline eval_coefficients (:: Type{T} , coeffs:: Tuple{Any, Any, Any} , t:: Number ) where T = (T (eval_coefficient (coeffs[1 ], t)), T (eval_coefficient (coeffs[2 ], t)), T (eval_coefficient (coeffs[3 ], t)))
299- @inline eval_coefficients (:: Type{T} , coeffs:: Tuple , t:: Number ) where T = (T (eval_coefficient (coeffs[1 ], t)), eval_coefficients (T, Base. tail (coeffs), t)... )
295+ # This is the performance-critical implementation. map(f, ::Tuple) avoids allocs in most cases
296+ @inline eval_coefficients (:: Type{T} , coeffs:: Tuple , t:: Number ) where T = map (c-> T (eval_coefficient (c, t)), coeffs)
300297
298+ # Now just using map here instead. Maybe restore this in case of regressions.
299+ # # To avoid allocations in most cases, we model this on map(f, t::Tuple).
300+ # @inline eval_coefficients(::Type{T}, coeffs::Tuple{Any,}, t::Number) where T = (T(eval_coefficient(coeffs[1], t)),)
301+ # @inline eval_coefficients(::Type{T}, coeffs::Tuple{Any, Any}, t::Number) where T = (T(eval_coefficient(coeffs[1], t)), T(eval_coefficient(coeffs[2], t)))
302+ # @inline eval_coefficients(::Type{T}, coeffs::Tuple{Any, Any, Any}, t::Number) where T = (T(eval_coefficient(coeffs[1], t)), T(eval_coefficient(coeffs[2], t)), T(eval_coefficient(coeffs[3], t)))
303+ # @inline eval_coefficients(::Type{T}, coeffs::Tuple, t::Number) where T = (T(eval_coefficient(coeffs[1], t)), eval_coefficients(T, Base.tail(coeffs), t)...)
301304
302305_timeshift_coeff (coeff, t0) = (@inline shifted_coeff (t) = coeff (t- t0))
303306_timeshift_coeff (coeff:: Number , _) = coeff
0 commit comments