1
Fork 0

coverage: Flatten guard logic in maybe_flush_pending_dups

This commit is contained in:
Zalathar 2023-10-16 20:56:16 +11:00
parent 97d1a9120e
commit 7bbe4be568

View file

@ -456,22 +456,23 @@ impl<'a> CoverageSpansGenerator<'a> {
/// In either case, no more spans will match the span of `pending_dups`, so /// In either case, no more spans will match the span of `pending_dups`, so
/// add the `pending_dups` if they don't overlap `curr`, and clear the list. /// add the `pending_dups` if they don't overlap `curr`, and clear the list.
fn maybe_flush_pending_dups(&mut self) { fn maybe_flush_pending_dups(&mut self) {
if let Some(dup) = self.pending_dups.last() let Some(last_dup) = self.pending_dups.last() else { return };
&& dup.span != self.prev().span if last_dup.span == self.prev().span {
{ return;
debug!( }
" SAME spans, but pending_dups are NOT THE SAME, so BCBs matched on \
previous iteration, or prev started a new disjoint span" debug!(
); " SAME spans, but pending_dups are NOT THE SAME, so BCBs matched on \
if dup.span.hi() <= self.curr().span.lo() { previous iteration, or prev started a new disjoint span"
let pending_dups = self.pending_dups.split_off(0); );
for dup in pending_dups.into_iter() { if last_dup.span.hi() <= self.curr().span.lo() {
debug!(" ...adding at least one pending={:?}", dup); let pending_dups = self.pending_dups.split_off(0);
self.push_refined_span(dup); for dup in pending_dups.into_iter() {
} debug!(" ...adding at least one pending={:?}", dup);
} else { self.push_refined_span(dup);
self.pending_dups.clear();
} }
} else {
self.pending_dups.clear();
} }
} }