@@ -1549,7 +1549,11 @@ const DEFAULT_STABLE_INDEX = SU.StableIndex(Int[])
15491549Given a symbolic variable `x`, check whether it is an indexed array symbolic. If it is,
15501550return the array and `true`. Otherwise, return `x, false`.
15511551"""
1552- function split_indexed_var (x:: SymbolicT )
1552+ SU. @cache limit = 500_000 function split_indexed_var (x:: SymbolicT ):: Tuple{SymbolicT, Bool}
1553+ return _split_indexed_var (x)
1554+ end
1555+
1556+ function _split_indexed_var (x:: SymbolicT )
15531557 return Moshi. Match. @match x begin
15541558 BSImpl. Term (; f, args) && if f === getindex end => (args[1 ], true )
15551559 BSImpl. Term (; f, args) && if f isa Operator && length (args) == 1 end => begin
@@ -1572,7 +1576,11 @@ end
15721576Given a symbolic variable `x`, assume `split_indexed_var(x)[2]` is `true`. Return the
15731577corresponding `SymbolicUtils.StableIndex`.
15741578"""
1575- function get_stable_index (x:: SymbolicT )
1579+ SU. @cache limit = 500_000 function get_stable_index (x:: SymbolicT ):: SU.StableIndex{Int}
1580+ return _get_stable_index (x)
1581+ end
1582+
1583+ function _get_stable_index (x:: SymbolicT )
15761584 return Moshi. Match. @match x begin
15771585 BSImpl. Term (; f, args) && if f === getindex end => return SU. StableIndex {Int} (x)
15781586 BSImpl. Term (; f, args) && if f isa Operator end => return get_stable_index (args[1 ])
0 commit comments