Skip to content

Commit a9363db

Browse files
committed
Fix .gcda parsing for C++ templates
1 parent cc77ce3 commit a9363db

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/parser.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,17 @@ pub fn parse_gcov_gz(gcov_path: &Path) -> Result<Vec<(String, CovResult)>, Parse
423423
let mut lines = BTreeMap::new();
424424
let mut branches = BTreeMap::new();
425425
for mut line in file.lines.drain(..) {
426-
lines.insert(line.line_number, line.count);
426+
lines.entry(line.line_number)
427+
.and_modify(|v|*v += line.count)
428+
.or_insert(line.count);
427429
if !line.branches.is_empty() {
428-
branches.insert(
429-
line.line_number,
430-
line.branches.drain(..).map(|b| b.count > 0).collect(),
431-
);
430+
let values: Vec<bool> = line.branches.drain(..).map(|b| b.count > 0).collect();
431+
branches.entry(line.line_number)
432+
.and_modify(|v: &mut Vec<bool>|
433+
v.iter_mut().zip(values.iter()).for_each(
434+
|(val, newval)|*val&=newval)
435+
)
436+
.or_insert(values);
432437
}
433438
}
434439
if lines.is_empty() {

0 commit comments

Comments
 (0)