Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/integrator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,8 @@ function step(
ϵ = fwd ? step_size(lf) : -step_size(lf)
ϵ = ϵ'

res = if FullTraj
Vector{P}(undef, n_steps)
else
Vector{P}(undef, 1)
if FullTraj
res = Vector{P}(undef, n_steps)
end

(; θ, r) = z
Expand All @@ -244,20 +242,18 @@ function step(
# Update result
if FullTraj
res[i] = z
else
res[1] = z
end
if !isfinite(z)
# Remove undef
if FullTraj
res = res[isassigned.(Ref(res), 1:n_steps)]
resize!(res, i)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed a bit useless to compute the not-undefed entries if we already know that exactly entries 1 to i are assigned some value.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! The resize is better than the previous one.

end
break
end
end
return if FullTraj
res
else
first(res)
z
end
end
Loading