@@ -228,9 +228,7 @@ impl<'a> MakeBcbCounters<'a> {
228228 debug ! ( "{:?} has at least one coverage span. Get or make its counter" , bcb) ;
229229 let branching_counter_operand = self . get_or_make_counter_operand ( bcb) ;
230230
231- if self . bcb_needs_branch_counters ( bcb) {
232- self . make_branch_counters ( & traversal, bcb, branching_counter_operand) ;
233- }
231+ self . make_branch_counters ( & traversal, bcb, branching_counter_operand) ;
234232 } else {
235233 debug ! (
236234 "{:?} does not have any coverage spans. A counter will only be added if \
@@ -254,6 +252,15 @@ impl<'a> MakeBcbCounters<'a> {
254252 branching_counter_operand : CovTerm ,
255253 ) {
256254 let branches = self . bcb_branches ( from_bcb) ;
255+
256+ // If this node doesn't have multiple out-edges, or all of its out-edges
257+ // already have counters, then we don't need to create edge counters.
258+ let needs_branch_counters =
259+ branches. len ( ) > 1 && branches. iter ( ) . any ( |branch| self . branch_has_no_counter ( branch) ) ;
260+ if !needs_branch_counters {
261+ return ;
262+ }
263+
257264 debug ! (
258265 "{from_bcb:?} has some branch(es) without counters:\n {}" ,
259266 branches
@@ -510,12 +517,6 @@ impl<'a> MakeBcbCounters<'a> {
510517 . collect :: < Vec < _ > > ( )
511518 }
512519
513- fn bcb_needs_branch_counters ( & self , bcb : BasicCoverageBlock ) -> bool {
514- let branch_needs_a_counter = |branch : & BcbBranch | self . branch_has_no_counter ( branch) ;
515- let branches = self . bcb_branches ( bcb) ;
516- branches. len ( ) > 1 && branches. iter ( ) . any ( branch_needs_a_counter)
517- }
518-
519520 fn branch_has_no_counter ( & self , branch : & BcbBranch ) -> bool {
520521 self . branch_counter ( branch) . is_none ( )
521522 }
0 commit comments