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,14 +456,16 @@ impl<'a> CoverageSpansGenerator<'a> {
/// 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.
fn maybe_flush_pending_dups(&mut self) {
if let Some(dup) = self.pending_dups.last()
&& dup.span != self.prev().span
{
let Some(last_dup) = self.pending_dups.last() else { return };
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"
);
if dup.span.hi() <= self.curr().span.lo() {
if last_dup.span.hi() <= self.curr().span.lo() {
let pending_dups = self.pending_dups.split_off(0);
for dup in pending_dups.into_iter() {
debug!(" ...adding at least one pending={:?}", dup);
@ -473,7 +475,6 @@ impl<'a> CoverageSpansGenerator<'a> {
self.pending_dups.clear();
}
}
}
/// Advance `prev` to `curr` (if any), and `curr` to the next `CoverageSpan` in sorted order.
fn next_coverage_span(&mut self) -> bool {