@@ -143,18 +143,24 @@ end
143
143
144
144
_split_helper (buf_v:: T , recurse, raw, idx) where {T} = _split_helper (eltype (T), buf_v, recurse, raw, idx)
145
145
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 )
148
148
end
149
149
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)
151
155
res = reshape (raw[idx[]: (idx[] + length (buf_v) - 1 )], size (buf_v))
152
156
idx[] += length (buf_v)
153
157
return res
154
158
end
155
159
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
158
164
end
159
165
160
166
function update_tuple_of_buffers (raw:: AbstractArray , buf)
@@ -197,7 +203,7 @@ for (Portion, field) in [(SciMLStructures.Tunable, :tunable)
197
203
@set! p.$ field = split_into_buffers (newvals, p.$ field)
198
204
if p. dependent_update_oop != = nothing
199
205
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 ) )
201
207
end
202
208
p
203
209
end
0 commit comments