@@ -80,19 +80,20 @@ impl CoverageCounters {
80
80
basic_coverage_blocks : & CoverageGraph ,
81
81
bcb_needs_counter : impl Fn ( BasicCoverageBlock ) -> bool ,
82
82
) -> Self {
83
- let num_bcbs = basic_coverage_blocks. num_nodes ( ) ;
83
+ let mut counters = MakeBcbCounters :: new ( basic_coverage_blocks) ;
84
+ counters. make_bcb_counters ( bcb_needs_counter) ;
84
85
85
- let mut this = Self {
86
+ counters. coverage_counters
87
+ }
88
+
89
+ fn with_num_bcbs ( num_bcbs : usize ) -> Self {
90
+ Self {
86
91
counter_increment_sites : IndexVec :: new ( ) ,
87
92
bcb_counters : IndexVec :: from_elem_n ( None , num_bcbs) ,
88
93
bcb_edge_counters : FxHashMap :: default ( ) ,
89
94
expressions : IndexVec :: new ( ) ,
90
95
expressions_memo : FxHashMap :: default ( ) ,
91
- } ;
92
-
93
- MakeBcbCounters :: new ( & mut this, basic_coverage_blocks) . make_bcb_counters ( bcb_needs_counter) ;
94
-
95
- this
96
+ }
96
97
}
97
98
98
99
/// Shared helper used by [`Self::make_phys_node_counter`] and
@@ -265,16 +266,16 @@ impl CoverageCounters {
265
266
266
267
/// Helper struct that allows counter creation to inspect the BCB graph.
267
268
struct MakeBcbCounters < ' a > {
268
- coverage_counters : & ' a mut CoverageCounters ,
269
+ coverage_counters : CoverageCounters ,
269
270
basic_coverage_blocks : & ' a CoverageGraph ,
270
271
}
271
272
272
273
impl < ' a > MakeBcbCounters < ' a > {
273
- fn new (
274
- coverage_counters : & ' a mut CoverageCounters ,
275
- basic_coverage_blocks : & ' a CoverageGraph ,
276
- ) -> Self {
277
- Self { coverage_counters , basic_coverage_blocks }
274
+ fn new ( basic_coverage_blocks : & ' a CoverageGraph ) -> Self {
275
+ Self {
276
+ coverage_counters : CoverageCounters :: with_num_bcbs ( basic_coverage_blocks . num_nodes ( ) ) ,
277
+ basic_coverage_blocks ,
278
+ }
278
279
}
279
280
280
281
fn make_bcb_counters ( & mut self , bcb_needs_counter : impl Fn ( BasicCoverageBlock ) -> bool ) {
0 commit comments