Skip to content

Commit 3c6b37e

Browse files
committed
Simplify setup function construction
1 parent e69ef19 commit 3c6b37e

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/systems/callbacks.jl

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -918,24 +918,21 @@ function generate_vector_rootfinding_callback(
918918
initialize = nothing
919919
if has_index_cache(sys) && (ic = get_index_cache(sys)) !== nothing
920920
initialize = handle_optional_setup_fn(
921-
map(
922-
(cb, fn) -> begin
923-
if (save_idxs = get(ic.callback_to_clocks, cb, nothing)) !== nothing
924-
let save_idxs = save_idxs
925-
custom_init = fn.initialize
926-
(i) -> begin
927-
isnothing(custom_init) && custom_init(i)
928-
for idx in save_idxs
929-
SciMLBase.save_discretes!(i, idx)
930-
end
921+
map(cbs, affect_functions) do cb, fn
922+
if (save_idxs = get(ic.callback_to_clocks, cb, nothing)) !== nothing
923+
let save_idxs = save_idxs
924+
custom_init = fn.initialize
925+
(i) -> begin
926+
isnothing(custom_init) && custom_init(i)
927+
for idx in save_idxs
928+
SciMLBase.save_discretes!(i, idx)
931929
end
932930
end
933-
else
934-
fn.initialize
935931
end
936-
end,
937-
cbs,
938-
affect_functions),
932+
else
933+
fn.initialize
934+
end
935+
end,
939936
SciMLBase.INITIALIZE_DEFAULT)
940937

941938
else

0 commit comments

Comments
 (0)