Skip to content

Commit

Permalink
reduce allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaLampert committed Dec 18, 2024
1 parent 192b40f commit 05a195b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/geometries/polytopes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,11 @@ function (c::Chain)(t)
if t < 0 || t > 1
throw(DomainError(t, "c(t) is not defined for t outside [0, 1]."))
end
s = collect(segments(c))
N = length(s)
k = max(1, ceil(Int, N * t))
s[k](N * t - k + 1)
v = vertices(c)
n = length(v) - !isclosed(c)
k = max(1, ceil(Int, n * t))
s, _ = iterate(segments(c), k)
s(n * t - k + 1)
end

# implementations of Chain
Expand Down

0 comments on commit 05a195b

Please sign in to comment.