@@ -143,18 +143,24 @@ end
143143
144144_split_helper (buf_v:: T , recurse, raw, idx) where {T} = _split_helper (eltype (T), buf_v, recurse, raw, idx)
145145
146- function _split_helper (:: Type{<:AbstractArray} , buf_v, recurse , raw, idx)
147- recurse ? map (b -> _split_helper (b, recurse, raw, idx ), buf_v) : _split_helper (Any, b, recurse , raw, idx)
146+ function _split_helper (:: Type{<:AbstractArray} , buf_v, :: Val{true} , raw, idx)
147+ map (b -> _split_helper (eltype (b ), b, Val ( false ) , raw, idx), buf_v )
148148end
149149
150- function _split_helper (:: Any , buf_v, recurse, raw, idx)
150+ function _split_helper (:: Type{<:AbstractArray} , buf_v, :: Val{false} , raw, idx)
151+ _split_helper ((), buf_v, (), raw, idx)
152+ end
153+
154+ function _split_helper (_, buf_v, _, raw, idx)
151155 res = reshape (raw[idx[]: (idx[] + length (buf_v) - 1 )], size (buf_v))
152156 idx[] += length (buf_v)
153157 return res
154158end
155159
156- function split_into_buffers (raw:: AbstractArray , buf; recurse = true )
157- ntuple (i-> _split_helper (buf[i], recurse, raw, Ref (1 )), Val (length (buf)))
160+ function split_into_buffers (raw:: AbstractArray , buf, recurse = Val (true ))
161+ idx = Ref (1 )
162+ ntuple (i-> _split_helper (buf[i], recurse, raw, idx), Val (length (buf)))
163+ end
158164end
159165
160166function update_tuple_of_buffers (raw:: AbstractArray , buf)
@@ -197,7 +203,7 @@ for (Portion, field) in [(SciMLStructures.Tunable, :tunable)
197203 @set! p.$ field = split_into_buffers (newvals, p.$ field)
198204 if p. dependent_update_oop != = nothing
199205 raw = p. dependent_update_oop (p... )
200- @set! p. dependent = split_into_buffers (raw, p. dependent; recurse = false )
206+ @set! p. dependent = split_into_buffers (raw, p. dependent, Val ( false ) )
201207 end
202208 p
203209 end
0 commit comments