Skip to content

Commit 254dea1

Browse files
authored
Update src/functor.jl
1 parent b020163 commit 254dea1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/functor.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ julia> fcollect(m, exclude = v -> Functors.isleaf(v))
193193
```
194194
"""
195195
function fcollect(x; output = [], cache = Base.IdSet(), exclude = v -> false)
196+
# note: we don't have an `OrderedIdSet`, so we use an `IdSet` for the cache
197+
# (to ensure we get exactly 1 copy of each distinct array), and a usual `Vector`
198+
# for the results, to preserve traversal order (important downstream!).
196199
x in cache && return output
197200
if !exclude(x)
198201
push!(cache, x)

0 commit comments

Comments
 (0)