Skip to content

Commit 2da4f8a

Browse files
committed
perf: make update_tuple_of_buffers type stable
1 parent 41018ea commit 2da4f8a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/systems/parameter_buffer.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,18 @@ function _update_tuple_helper(buf_v::T, raw, idx) where {T}
172172
end
173173

174174
function _update_tuple_helper(::Type{<:AbstractArray}, buf_v, raw, idx)
175-
map(b -> _update_tuple_helper(b, raw, idx), buf_v)
175+
ntuple(i -> _update_tuple_helper(buf_v[i], raw, idx), Val(length(buf_v)))
176176
end
177177

178178
function _update_tuple_helper(::Any, buf_v, raw, idx)
179179
copyto!(buf_v, view(raw, idx[]:(idx[] + length(buf_v) - 1)))
180180
idx[] += length(buf_v)
181+
return nothing
181182
end
182183

183184
function update_tuple_of_buffers(raw::AbstractArray, buf)
184185
idx = Ref(1)
185-
map(b -> _update_tuple_helper(b, raw, idx), buf)
186+
ntuple(i -> _update_tuple_helper(buf[i], raw, idx), Val(length(buf)))
186187
end
187188

188189
SciMLStructures.isscimlstructure(::MTKParameters) = true

0 commit comments

Comments
 (0)