@@ -226,9 +226,7 @@ impl<'a> MakeBcbCounters<'a> {
226
226
debug ! ( "{:?} has at least one coverage span. Get or make its counter" , bcb) ;
227
227
let branching_counter_operand = self . get_or_make_counter_operand ( bcb) ;
228
228
229
- if self . bcb_needs_branch_counters ( bcb) {
230
- self . make_branch_counters ( & traversal, bcb, branching_counter_operand) ;
231
- }
229
+ self . make_branch_counters ( & traversal, bcb, branching_counter_operand) ;
232
230
} else {
233
231
debug ! (
234
232
"{:?} does not have any coverage spans. A counter will only be added if \
@@ -252,6 +250,15 @@ impl<'a> MakeBcbCounters<'a> {
252
250
branching_counter_operand : CovTerm ,
253
251
) {
254
252
let branches = self . bcb_branches ( from_bcb) ;
253
+
254
+ // If this node doesn't have multiple out-edges, or all of its out-edges
255
+ // already have counters, then we don't need to create edge counters.
256
+ let needs_branch_counters =
257
+ branches. len ( ) > 1 && branches. iter ( ) . any ( |branch| self . branch_has_no_counter ( branch) ) ;
258
+ if !needs_branch_counters {
259
+ return ;
260
+ }
261
+
255
262
debug ! (
256
263
"{from_bcb:?} has some branch(es) without counters:\n {}" ,
257
264
branches
@@ -508,12 +515,6 @@ impl<'a> MakeBcbCounters<'a> {
508
515
. collect :: < Vec < _ > > ( )
509
516
}
510
517
511
- fn bcb_needs_branch_counters ( & self , bcb : BasicCoverageBlock ) -> bool {
512
- let branch_needs_a_counter = |branch : & BcbBranch | self . branch_has_no_counter ( branch) ;
513
- let branches = self . bcb_branches ( bcb) ;
514
- branches. len ( ) > 1 && branches. iter ( ) . any ( branch_needs_a_counter)
515
- }
516
-
517
518
fn branch_has_no_counter ( & self , branch : & BcbBranch ) -> bool {
518
519
self . branch_counter ( branch) . is_none ( )
519
520
}
0 commit comments