Skip to content

Commit 3677a02

Browse files
committed
Make set_constants! lighter weight
1 parent 05a695c commit 3677a02

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/EquationUtils.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ Set the constants in a tree, in depth-first order. The function
104104
function set_constants!(
105105
tree::AbstractExpressionNode{T}, constants::AbstractVector{T}
106106
) where {T}
107-
_constants = copy(constants)
107+
Base.require_one_based_indexing(constants)
108+
i = Ref(0)
108109
foreach(tree) do node
109110
if node.degree == 0 && node.constant
110-
node.val = popfirst!(_constants)
111+
@inbounds node.val = constants[i[] += 1]
111112
end
112113
end
113114
return nothing

0 commit comments

Comments
 (0)