@@ -24,7 +24,8 @@ private struct TopologicalSorting {
2424 private let store : AtomStore
2525 private( set) var edges = ContiguousArray < Edge < AtomKey > > ( )
2626 private( set) var subscriptionEdges = ContiguousArray < Edge < Subscription > > ( )
27- private var trace = Set < Vertex > ( )
27+ private var atomTrace = Set < AtomKey > ( )
28+ private var subscriberTrace = Set < SubscriberKey > ( )
2829
2930 init ( key: AtomKey , store: AtomStore ) {
3031 self . key = key
@@ -37,15 +38,10 @@ private struct TopologicalSorting {
3738}
3839
3940private extension TopologicalSorting {
40- enum Vertex : Hashable {
41- case atom( key: AtomKey )
42- case subscriber( key: SubscriberKey )
43- }
44-
4541 mutating func traverse( key: AtomKey ) {
4642 if let children = store. graph. children [ key] {
4743 for child in ContiguousArray ( children) {
48- guard !trace . contains ( . atom ( key : child) ) else {
44+ guard !atomTrace . contains ( child) else {
4945 continue
5046 }
5147
@@ -55,21 +51,21 @@ private extension TopologicalSorting {
5551
5652 if let subscriptions = store. state. subscriptions [ key] {
5753 for (subscriberKey, subscription) in ContiguousArray ( subscriptions) {
58- guard !trace . contains ( . subscriber ( key : subscriberKey) ) else {
54+ guard !subscriberTrace . contains ( subscriberKey) else {
5955 continue
6056 }
6157
6258 let edge = Edge ( from: key, to: subscription)
6359 subscriptionEdges. append ( edge)
64- trace . insert ( . subscriber ( key : subscriberKey) )
60+ subscriberTrace . insert ( subscriberKey)
6561 }
6662 }
6763 }
6864
6965 mutating func traverse( key: AtomKey , from fromKey: AtomKey ) {
7066 let edge = Edge ( from: fromKey, to: key)
7167
72- trace . insert ( . atom ( key: key ) )
68+ atomTrace . insert ( key)
7369 traverse ( key: key)
7470 edges. append ( edge)
7571 }
0 commit comments