diff options
| author | Amanda Stjerna <amanda.stjerna@it.uu.se> | 2024-05-17 15:11:59 +0200 |
|---|---|---|
| committer | Amanda Stjerna <amanda.stjerna@it.uu.se> | 2024-06-12 15:47:32 +0200 |
| commit | 905db03b2869d6c53893ccddd84d8b2fd3c48273 (patch) | |
| tree | 8a6ca2b5e6eb5d63efc32a101358f7b015261d96 /compiler/rustc_data_structures/src/graph/scc | |
| parent | d2a01760bcc82302464632e38d2108e06c2a8dd9 (diff) | |
| download | rust-905db03b2869d6c53893ccddd84d8b2fd3c48273.tar.gz rust-905db03b2869d6c53893ccddd84d8b2fd3c48273.zip | |
Simplify path compression logic
Diffstat (limited to 'compiler/rustc_data_structures/src/graph/scc')
| -rw-r--r-- | compiler/rustc_data_structures/src/graph/scc/mod.rs | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs index 68a055553a1..1426aa2baa4 100644 --- a/compiler/rustc_data_structures/src/graph/scc/mod.rs +++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs @@ -393,38 +393,23 @@ where // `InCycleWith` upwards. // This loop performs the downward link encoding mentioned above. Details below! let node_state = { - let mut annotation = (self.to_annotation)(node); - loop { debug!("find_state(r = {node:?} in state {:?})", self.node_states[node]); match self.node_states[node] { - NodeState::NotVisited => break NodeState::NotVisited, - NodeState::BeingVisited { depth, annotation: previous_annotation } => { - break NodeState::BeingVisited { - depth, - annotation: previous_annotation.merge_scc(annotation), - }; - } + s @ (NodeState::NotVisited | NodeState::BeingVisited{..} | NodeState::InCycle { .. }) => break s, NodeState::InCycleWith { parent } => { // We test this, to be extremely sure that we never // ever break our termination condition for the // reverse iteration loop. assert!(node != parent, "Node can not be in cycle with itself"); - annotation = annotation.merge_scc((self.to_annotation)(node)); - // Store the previous node as an inverted list link self.node_states[node] = NodeState::InCycleWith { parent: previous_node }; // Update to parent node. previous_node = node; node = parent; } - NodeState::InCycle { scc_index, annotation: previous_annotation } => { - break NodeState::InCycle { - scc_index, - annotation: previous_annotation.merge_scc(annotation), - }; - } + } } }; |
