coverage: Simplify push_refined_span
It turns out that all of the `len` manipulation here was just reimplementing `last_mut`.
This commit is contained in:
parent
fa2e26285c
commit
5f1e8f9950
@ -384,19 +384,15 @@ fn to_refined_spans(mut self) -> Vec<CoverageSpan> {
|
||||
}
|
||||
|
||||
fn push_refined_span(&mut self, covspan: CoverageSpan) {
|
||||
let len = self.refined_spans.len();
|
||||
if len > 0 {
|
||||
let last = &mut self.refined_spans[len - 1];
|
||||
if last.is_mergeable(&covspan) {
|
||||
debug!(
|
||||
"merging new refined span with last refined span, last={:?}, covspan={:?}",
|
||||
last, covspan
|
||||
);
|
||||
last.merge_from(covspan);
|
||||
return;
|
||||
}
|
||||
if let Some(last) = self.refined_spans.last_mut()
|
||||
&& last.is_mergeable(&covspan)
|
||||
{
|
||||
// Instead of pushing the new span, merge it with the last refined span.
|
||||
debug!(?last, ?covspan, "merging new refined span with last refined span");
|
||||
last.merge_from(covspan);
|
||||
} else {
|
||||
self.refined_spans.push(covspan);
|
||||
}
|
||||
self.refined_spans.push(covspan)
|
||||
}
|
||||
|
||||
/// If `curr` is part of a new macro expansion, carve out and push a separate
|
||||
|
Loading…
Reference in New Issue
Block a user