1
Fork 0

coverage: Flatten some graph code with let-else

This commit is contained in:
Zalathar 2024-06-16 13:01:41 +10:00
parent 917b455a87
commit dca6b5eead

View file

@ -419,26 +419,25 @@ impl<'a> TraverseCoverageGraphWithLoops<'a> {
); );
while let Some(context) = self.context_stack.last_mut() { while let Some(context) = self.context_stack.last_mut() {
if let Some(bcb) = context.worklist.pop_front() { let Some(bcb) = context.worklist.pop_front() else {
if !self.visited.insert(bcb) { // This stack level is exhausted; pop it and try the next one.
debug!("Already visited: {bcb:?}");
continue;
}
debug!("Visiting {bcb:?}");
if self.backedges[bcb].len() > 0 {
debug!("{bcb:?} is a loop header! Start a new TraversalContext...");
self.context_stack.push(TraversalContext {
loop_header: Some(bcb),
worklist: VecDeque::new(),
});
}
self.add_successors_to_worklists(bcb);
return Some(bcb);
} else {
// Strip contexts with empty worklists from the top of the stack
self.context_stack.pop(); self.context_stack.pop();
continue;
};
if !self.visited.insert(bcb) {
debug!("Already visited: {bcb:?}");
continue;
} }
debug!("Visiting {bcb:?}");
if self.backedges[bcb].len() > 0 {
debug!("{bcb:?} is a loop header! Start a new TraversalContext...");
self.context_stack
.push(TraversalContext { loop_header: Some(bcb), worklist: VecDeque::new() });
}
self.add_successors_to_worklists(bcb);
return Some(bcb);
} }
None None