Convert some match
expressions to if
s.
These make the code more concise.
This commit is contained in:
parent
6fb1f37888
commit
9e67f19eee
@ -481,12 +481,8 @@ impl<O: ForestObligation> ObligationForest<O> {
|
|||||||
// For some benchmarks this state test is extremely
|
// For some benchmarks this state test is extremely
|
||||||
// hot. It's a win to handle the no-op cases immediately to avoid
|
// hot. It's a win to handle the no-op cases immediately to avoid
|
||||||
// the cost of the function call.
|
// the cost of the function call.
|
||||||
match node.state.get() {
|
if node.state.get() == NodeState::Success {
|
||||||
// Match arms are in order of frequency. Pending, Success and
|
self.find_cycles_from_node(&mut stack, processor, index);
|
||||||
// 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 => {},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,34 +495,25 @@ impl<O: ForestObligation> ObligationForest<O> {
|
|||||||
where P: ObligationProcessor<Obligation=O>
|
where P: ObligationProcessor<Obligation=O>
|
||||||
{
|
{
|
||||||
let node = &self.nodes[index];
|
let node = &self.nodes[index];
|
||||||
match node.state.get() {
|
if node.state.get() == NodeState::Success {
|
||||||
NodeState::Success => {
|
match stack.iter().rposition(|&n| n == index) {
|
||||||
match stack.iter().rposition(|&n| n == index) {
|
None => {
|
||||||
None => {
|
stack.push(index);
|
||||||
stack.push(index);
|
for &index in node.dependents.iter() {
|
||||||
for &index in node.dependents.iter() {
|
self.find_cycles_from_node(stack, processor, index);
|
||||||
self.find_cycles_from_node(stack, processor, index);
|
|
||||||
}
|
|
||||||
stack.pop();
|
|
||||||
node.state.set(NodeState::Done);
|
|
||||||
}
|
|
||||||
Some(rpos) => {
|
|
||||||
// Cycle detected.
|
|
||||||
processor.process_backedge(
|
|
||||||
stack[rpos..].iter().map(GetObligation(&self.nodes)),
|
|
||||||
PhantomData
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
stack.pop();
|
||||||
|
node.state.set(NodeState::Done);
|
||||||
|
}
|
||||||
|
Some(rpos) => {
|
||||||
|
// Cycle detected.
|
||||||
|
processor.process_backedge(
|
||||||
|
stack[rpos..].iter().map(GetObligation(&self.nodes)),
|
||||||
|
PhantomData
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NodeState::Waiting | NodeState::Pending => {
|
}
|
||||||
// This node is still reachable from some pending node. We
|
|
||||||
// will get to it when they are all processed.
|
|
||||||
}
|
|
||||||
NodeState::Done | NodeState::Error => {
|
|
||||||
// Already processed that node.
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a vector of obligations for `p` and all of its
|
/// Returns a vector of obligations for `p` and all of its
|
||||||
@ -553,12 +540,10 @@ impl<O: ForestObligation> ObligationForest<O> {
|
|||||||
|
|
||||||
while let Some(index) = error_stack.pop() {
|
while let Some(index) = error_stack.pop() {
|
||||||
let node = &self.nodes[index];
|
let node = &self.nodes[index];
|
||||||
match node.state.get() {
|
if node.state.get() != NodeState::Error {
|
||||||
NodeState::Error => continue,
|
node.state.set(NodeState::Error);
|
||||||
_ => node.state.set(NodeState::Error),
|
error_stack.extend(node.dependents.iter());
|
||||||
}
|
}
|
||||||
|
|
||||||
error_stack.extend(node.dependents.iter());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trace
|
trace
|
||||||
|
Loading…
x
Reference in New Issue
Block a user