coverage: Have MakeBcbCounters own its CoverageCounters
This commit is contained in:
parent
3f90bb15ed
commit
c6e4fcd4fa
1 changed files with 14 additions and 13 deletions
|
@ -80,19 +80,20 @@ impl CoverageCounters {
|
||||||
basic_coverage_blocks: &CoverageGraph,
|
basic_coverage_blocks: &CoverageGraph,
|
||||||
bcb_needs_counter: impl Fn(BasicCoverageBlock) -> bool,
|
bcb_needs_counter: impl Fn(BasicCoverageBlock) -> bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let num_bcbs = basic_coverage_blocks.num_nodes();
|
let mut counters = MakeBcbCounters::new(basic_coverage_blocks);
|
||||||
|
counters.make_bcb_counters(bcb_needs_counter);
|
||||||
|
|
||||||
let mut this = Self {
|
counters.coverage_counters
|
||||||
|
}
|
||||||
|
|
||||||
|
fn with_num_bcbs(num_bcbs: usize) -> Self {
|
||||||
|
Self {
|
||||||
counter_increment_sites: IndexVec::new(),
|
counter_increment_sites: IndexVec::new(),
|
||||||
bcb_counters: IndexVec::from_elem_n(None, num_bcbs),
|
bcb_counters: IndexVec::from_elem_n(None, num_bcbs),
|
||||||
bcb_edge_counters: FxHashMap::default(),
|
bcb_edge_counters: FxHashMap::default(),
|
||||||
expressions: IndexVec::new(),
|
expressions: IndexVec::new(),
|
||||||
expressions_memo: FxHashMap::default(),
|
expressions_memo: FxHashMap::default(),
|
||||||
};
|
}
|
||||||
|
|
||||||
MakeBcbCounters::new(&mut this, basic_coverage_blocks).make_bcb_counters(bcb_needs_counter);
|
|
||||||
|
|
||||||
this
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shared helper used by [`Self::make_phys_node_counter`] and
|
/// Shared helper used by [`Self::make_phys_node_counter`] and
|
||||||
|
@ -265,16 +266,16 @@ impl CoverageCounters {
|
||||||
|
|
||||||
/// Helper struct that allows counter creation to inspect the BCB graph.
|
/// Helper struct that allows counter creation to inspect the BCB graph.
|
||||||
struct MakeBcbCounters<'a> {
|
struct MakeBcbCounters<'a> {
|
||||||
coverage_counters: &'a mut CoverageCounters,
|
coverage_counters: CoverageCounters,
|
||||||
basic_coverage_blocks: &'a CoverageGraph,
|
basic_coverage_blocks: &'a CoverageGraph,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> MakeBcbCounters<'a> {
|
impl<'a> MakeBcbCounters<'a> {
|
||||||
fn new(
|
fn new(basic_coverage_blocks: &'a CoverageGraph) -> Self {
|
||||||
coverage_counters: &'a mut CoverageCounters,
|
Self {
|
||||||
basic_coverage_blocks: &'a CoverageGraph,
|
coverage_counters: CoverageCounters::with_num_bcbs(basic_coverage_blocks.num_nodes()),
|
||||||
) -> Self {
|
basic_coverage_blocks,
|
||||||
Self { coverage_counters, basic_coverage_blocks }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_bcb_counters(&mut self, bcb_needs_counter: impl Fn(BasicCoverageBlock) -> bool) {
|
fn make_bcb_counters(&mut self, bcb_needs_counter: impl Fn(BasicCoverageBlock) -> bool) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue