Skip to content

Commit 41018ea

Browse files
committed
perf: make buffer_to_arraypartition type inferable
1 parent 848bf41 commit 41018ea

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/systems/parameter_buffer.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,13 @@ function MTKParameters(
137137
end
138138

139139
function buffer_to_arraypartition(buf)
140-
return ArrayPartition(Tuple(eltype(v) <: AbstractArray ? buffer_to_arraypartition(v) :
141-
v for v in buf))
140+
return ArrayPartition(ntuple(i -> _buffer_to_arrp_helper(buf[i]), Val(length(buf))))
142141
end
143142

143+
_buffer_to_arrp_helper(v::T) where {T} = _buffer_to_arrp_helper(eltype(T), v)
144+
_buffer_to_arrp_helper(::Type{<:AbstractArray}, v) = buffer_to_arraypartition(v)
145+
_buffer_to_arrp_helper(::Any, v) = v
146+
144147
function _split_helper(buf_v::T, recurse, raw, idx) where {T}
145148
_split_helper(eltype(T), buf_v, recurse, raw, idx)
146149
end

0 commit comments

Comments
 (0)