in src/reader.rs [970:1030]
fn look_for_circuit(
fun_edges: &mut [GcovEdge],
fun_blocks: &[GcovBlock],
v: usize,
start: usize,
path: &mut SmallVec<[usize; 4]>,
blocked: &mut SmallVec<[usize; 4]>,
block_lists: &mut SmallVec<[SmallVec<[usize; 2]>; 2]>,
blocks: &[usize],
) -> (bool, u64) {
let mut count = 0;
blocked.push(v);
block_lists.push(SmallVec::new());
let mut found = false;
let dsts = &fun_blocks[v].destination;
for e in dsts {
let w = fun_edges[*e].destination;
if w >= start && blocks.contains(&w) {
path.push(*e);
if w == start {
count += GcovFunction::get_cycle_count(fun_edges, path);
found = true;
} else if blocked.iter().all(|x| *x != w) {
let (f, c) = GcovFunction::look_for_circuit(
fun_edges,
fun_blocks,
w,
start,
path,
blocked,
block_lists,
blocks,
);
count += c;
if f {
found = true;
}
}
path.pop();
}
}
if found {
GcovFunction::unblock(v, blocked, block_lists);
} else {
for e in dsts {
let w = fun_edges[*e].destination;
if w >= start || blocks.contains(&w) {
if let Some(i) = blocked.iter().position(|x| *x == w) {
let list = &mut block_lists[i];
if list.iter().all(|x| *x != v) {
list.push(v);
}
}
}
}
}
(found, count)
}