From e8588fed460dc8c7e719c42815d4a861bcaec4fa Mon Sep 17 00:00:00 2001 From: oscarddssmith Date: Mon, 29 Apr 2024 10:10:14 -0400 Subject: [PATCH 1/2] fix remaining allocations --- src/preset_time.jl | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/preset_time.jl b/src/preset_time.jl index 4c327b70..470fa285 100644 --- a/src/preset_time.jl +++ b/src/preset_time.jl @@ -30,19 +30,23 @@ function PresetTimeCallback(tstops, user_affect!; else tstops = sort(tstops) end - condition = function (u, t, integrator) - if hasproperty(integrator, :dt) - insorted(t, tstops) && (integrator.t - integrator.dt) != integrator.t - else - insorted(t, tstops) + condition = let tstops=tstops + function (u, t, integrator) + if hasproperty(integrator, :dt) + insorted(t, tstops) && (integrator.t - integrator.dt) != integrator.t + else + insorted(t, tstops) + end end end elseif tstops isa Number - condition = function (u, t, integrator) - if hasproperty(integrator, :dt) - t == tstops && (integrator.t - integrator.dt) != integrator.t - else - t == tstops + condition = let tstops=tstops + function (u, t, integrator) + if hasproperty(integrator, :dt) + t == tstops && (integrator.t - integrator.dt) != integrator.t + else + t == tstops + end end end else From b31171531722d069a84163c90a0def68bdd3881a Mon Sep 17 00:00:00 2001 From: oscarddssmith Date: Mon, 29 Apr 2024 10:29:29 -0400 Subject: [PATCH 2/2] format --- src/preset_time.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/preset_time.jl b/src/preset_time.jl index 470fa285..fb4faa01 100644 --- a/src/preset_time.jl +++ b/src/preset_time.jl @@ -30,7 +30,7 @@ function PresetTimeCallback(tstops, user_affect!; else tstops = sort(tstops) end - condition = let tstops=tstops + condition = let tstops = tstops function (u, t, integrator) if hasproperty(integrator, :dt) insorted(t, tstops) && (integrator.t - integrator.dt) != integrator.t @@ -40,7 +40,7 @@ function PresetTimeCallback(tstops, user_affect!; end end elseif tstops isa Number - condition = let tstops=tstops + condition = let tstops = tstops function (u, t, integrator) if hasproperty(integrator, :dt) t == tstops && (integrator.t - integrator.dt) != integrator.t