Skip to content

Commit f9e5c33

Browse files
Merge pull request #617 from SciML/s/states_to_sym
make states_to_sym fast in checking membership
2 parents ffb8057 + 53fbba0 commit f9e5c33

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/utils.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ end
119119

120120
@deprecate substitute_expr!(expr,s) substitute(expr,s)
121121

122-
function states_to_sym(states)
122+
function states_to_sym(states::Set)
123123
function _states_to_sym(O)
124124
if O isa Equation
125125
Expr(:(=), _states_to_sym(O.lhs), _states_to_sym(O.rhs))
126126
elseif O isa Term
127127
if isa(O.op, Sym)
128-
any(isequal(O), states) && return O.op.name # dependent variables
128+
O in states && return O.op.name # dependent variables
129129
return build_expr(:call, Any[O.op.name; _states_to_sym.(O.args)])
130130
else
131131
return build_expr(:call, Any[O.op; _states_to_sym.(O.args)])
@@ -137,6 +137,7 @@ function states_to_sym(states)
137137
end
138138
end
139139
end
140+
states_to_sym(states) = states_to_sym(Set(states))
140141

141142
"""
142143
toparam(s::Sym) -> Sym{<:Parameter}

0 commit comments

Comments
 (0)