@@ -315,20 +315,20 @@ impl<'a> MakeBcbCounters<'a> {
315
315
// For each out-edge other than the one that was chosen to get an expression,
316
316
// ensure that it has a counter (existing counter/expression or a new counter),
317
317
// and accumulate the corresponding counters into a single sum expression.
318
- let sum_of_all_other_out_edges : BcbCounter = {
319
- let _span = debug_span ! ( "sum_of_all_other_out_edges" , ?expression_to_bcb ) . entered ( ) ;
320
- successors
321
- . iter ( )
322
- . copied ( )
323
- // Skip the chosen edge, since we'll calculate its count from this sum.
324
- . filter ( | & to_bcb| to_bcb != expression_to_bcb )
325
- . fold ( None , |accum , to_bcb| {
326
- let _span = debug_span ! ( "to_bcb" , ?accum , ?to_bcb ) . entered ( ) ;
327
- let edge_counter = self . get_or_make_edge_counter ( from_bcb , to_bcb ) ;
328
- Some ( self . coverage_counters . make_sum_expression ( accum, edge_counter) )
329
- } )
330
- . expect ( "there must be at least one other out-edge" )
331
- } ;
318
+ let other_out_edge_counters = successors
319
+ . iter ( )
320
+ . copied ( )
321
+ // Skip the chosen edge, since we'll calculate its count from this sum.
322
+ . filter ( | & to_bcb| to_bcb != expression_to_bcb )
323
+ . map ( |to_bcb| self . get_or_make_edge_counter ( from_bcb , to_bcb ) )
324
+ . collect :: < Vec < _ > > ( ) ;
325
+ let sum_of_all_other_out_edges : BcbCounter = other_out_edge_counters
326
+ . iter ( )
327
+ . copied ( )
328
+ . fold ( None , | accum, edge_counter| {
329
+ Some ( self . coverage_counters . make_sum_expression ( accum , edge_counter ) )
330
+ } )
331
+ . expect ( "there must be at least one other out-edge" ) ;
332
332
333
333
// Now create an expression for the chosen edge, by taking the counter
334
334
// for its source node and subtracting the sum of its sibling out-edges.
@@ -375,20 +375,18 @@ impl<'a> MakeBcbCounters<'a> {
375
375
376
376
// A BCB with multiple incoming edges can compute its count by ensuring that counters
377
377
// exist for each of those edges, and then adding them up to get a total count.
378
- let sum_of_in_edges: BcbCounter = {
379
- let _span = debug_span ! ( "sum_of_in_edges" , ?bcb) . entered ( ) ;
380
- // We avoid calling `self.bcb_predecessors` here so that we can
381
- // call methods on `&mut self` inside the fold.
382
- self . basic_coverage_blocks . predecessors [ bcb]
383
- . iter ( )
384
- . copied ( )
385
- . fold ( None , |accum, from_bcb| {
386
- let _span = debug_span ! ( "from_bcb" , ?accum, ?from_bcb) . entered ( ) ;
387
- let edge_counter = self . get_or_make_edge_counter ( from_bcb, bcb) ;
388
- Some ( self . coverage_counters . make_sum_expression ( accum, edge_counter) )
389
- } )
390
- . expect ( "there must be at least one in-edge" )
391
- } ;
378
+ let in_edge_counters = self . basic_coverage_blocks . predecessors [ bcb]
379
+ . iter ( )
380
+ . copied ( )
381
+ . map ( |from_bcb| self . get_or_make_edge_counter ( from_bcb, bcb) )
382
+ . collect :: < Vec < _ > > ( ) ;
383
+ let sum_of_in_edges: BcbCounter = in_edge_counters
384
+ . iter ( )
385
+ . copied ( )
386
+ . fold ( None , |accum, edge_counter| {
387
+ Some ( self . coverage_counters . make_sum_expression ( accum, edge_counter) )
388
+ } )
389
+ . expect ( "there must be at least one in-edge" ) ;
392
390
393
391
debug ! ( "{bcb:?} gets a new counter (sum of predecessor counters): {sum_of_in_edges:?}" ) ;
394
392
self . coverage_counters . set_bcb_counter ( bcb, sum_of_in_edges)
0 commit comments