about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/graph/scc/mod.rs
diff options
context:
space:
mode:
authorAmanda Stjerna <amanda.stjerna@it.uu.se>2024-05-20 13:25:55 +0200
committerAmanda Stjerna <amanda.stjerna@it.uu.se>2024-06-12 15:47:32 +0200
commitaee846224cfaf6679acbf30986e6d2bb0de769ea (patch)
tree869edf32e00d8f1d3fec5d5731689e25ff425b7a /compiler/rustc_data_structures/src/graph/scc/mod.rs
parentb1add7bc046bce3dd1d31175486d160d8af52674 (diff)
downloadrust-aee846224cfaf6679acbf30986e6d2bb0de769ea.tar.gz
rust-aee846224cfaf6679acbf30986e6d2bb0de769ea.zip
Remove a few unnecessary constructions
This shaves off ca 6% of the cycles in `start_walk_from()` in my
experiments.
Diffstat (limited to 'compiler/rustc_data_structures/src/graph/scc/mod.rs')
-rw-r--r--compiler/rustc_data_structures/src/graph/scc/mod.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/rustc_data_structures/src/graph/scc/mod.rs b/compiler/rustc_data_structures/src/graph/scc/mod.rs
index 2ce155bb316..22b029c2bd4 100644
--- a/compiler/rustc_data_structures/src/graph/scc/mod.rs
+++ b/compiler/rustc_data_structures/src/graph/scc/mod.rs
@@ -535,7 +535,6 @@ where
             successors_len: 0,
             min_cycle_root: initial,
             successor_node: initial,
-            // Strictly speaking not necessary, but assumed to be idempotent:
             current_component_annotation: (self.to_annotation)(initial),
         }];
 
@@ -556,7 +555,9 @@ where
             let depth = *depth;
 
             // node is definitely in the current component, add it to the annotation.
-            current_component_annotation.update_scc((self.to_annotation)(node));
+            if node != initial {
+                current_component_annotation.update_scc((self.to_annotation)(node));
+            }
             debug!(
                 "Visiting {node:?} at depth {depth:?}, annotation: {current_component_annotation:?}"
             );
@@ -570,8 +571,10 @@ where
                     debug_assert!(matches!(self.node_states[node], NodeState::NotVisited));
 
                     // Push `node` onto the stack.
-                    self.node_states[node] =
-                        NodeState::BeingVisited { depth, annotation: (self.to_annotation)(node) };
+                    self.node_states[node] = NodeState::BeingVisited {
+                        depth,
+                        annotation: *current_component_annotation,
+                    };
                     self.node_stack.push(node);
 
                     // Walk each successor of the node, looking to see if any of