From f78efecc10e83c130c77ebfe7153a9c85cd5e36c Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Mon, 20 Nov 2023 15:17:24 -0500 Subject: [PATCH] Minor simplification I was reading this code to move it to sundials and realized that the `empty` case isn't necessary (since a loop over an empty list executes 0 times). This is nfc, but a slight readability improvement. --- src/solve.jl | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/solve.jl b/src/solve.jl index 901f3cf730..5d73383239 100644 --- a/src/solve.jl +++ b/src/solve.jl @@ -587,21 +587,15 @@ end tdir_t0 = tdir * t0 tdir_tf = tdir * tf - if isempty(d_discontinuities) && isempty(tstops) # TODO: Specialize more - push!(tstops_internal, tdir_tf) - else - for t in tstops - tdir_t = tdir * t - tdir_t0 < tdir_t ≤ tdir_tf && push!(tstops_internal, tdir_t) - end - - for t in d_discontinuities - tdir_t = tdir * t - tdir_t0 < tdir_t ≤ tdir_tf && push!(tstops_internal, tdir_t) - end - - push!(tstops_internal, tdir_tf) + for t in tstops + tdir_t = tdir * t + tdir_t0 < tdir_t ≤ tdir_tf && push!(tstops_internal, tdir_t) + end + for t in d_discontinuities + tdir_t = tdir * t + tdir_t0 < tdir_t ≤ tdir_tf && push!(tstops_internal, tdir_t) end + push!(tstops_internal, tdir_tf) return tstops_internal end