]> git.lizzy.rs Git - rust.git/commitdiff
Reorder the state handling in `process_cycles()`.
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 19 Sep 2019 06:51:41 +0000 (16:51 +1000)
committerNicholas Nethercote <nnethercote@mozilla.com>
Thu, 19 Sep 2019 21:22:10 +0000 (07:22 +1000)
This gives a slight speed-up.

src/librustc_data_structures/obligation_forest/mod.rs

index 98ae1a58324476c5c1731d32a20b1d13f97a0bb3..37f4537f4b770ffaa4041c9145e416e638ea9d35 100644 (file)
@@ -484,13 +484,16 @@ fn process_cycles<P>(&self, processor: &mut P)
         debug!("process_cycles()");
 
         for (index, node) in self.nodes.iter().enumerate() {
-            // For rustc-benchmarks/inflate-0.1.0 this state test is extremely
-            // hot and the state is almost always `Pending` or `Waiting`. It's
-            // a win to handle the no-op cases immediately to avoid the cost of
-            // the function call.
+            // For some benchmarks this state test is extremely
+            // hot. It's a win to handle the no-op cases immediately to avoid
+            // the cost of the function call.
             match node.state.get() {
-                NodeState::Waiting | NodeState::Pending | NodeState::Done | NodeState::Error => {},
-                _ => self.find_cycles_from_node(&mut stack, processor, index),
+                // Match arms are in order of frequency. Pending, Success and
+                // Waiting dominate; the others are rare.
+                NodeState::Pending => {},
+                NodeState::Success => self.find_cycles_from_node(&mut stack, processor, index),
+                NodeState::Waiting | NodeState::Done | NodeState::Error => {},
+                NodeState::OnDfsStack => self.find_cycles_from_node(&mut stack, processor, index),
             }
         }