@@ -23,19 +23,13 @@ pub struct Preorder<'a, 'tcx> {
23
23
body : & ' a Body < ' tcx > ,
24
24
visited : DenseBitSet < BasicBlock > ,
25
25
worklist : Vec < BasicBlock > ,
26
- root_is_start_block : bool ,
27
26
}
28
27
29
28
impl < ' a , ' tcx > Preorder < ' a , ' tcx > {
30
29
pub fn new ( body : & ' a Body < ' tcx > , root : BasicBlock ) -> Preorder < ' a , ' tcx > {
31
30
let worklist = vec ! [ root] ;
32
31
33
- Preorder {
34
- body,
35
- visited : DenseBitSet :: new_empty ( body. basic_blocks . len ( ) ) ,
36
- worklist,
37
- root_is_start_block : root == START_BLOCK ,
38
- }
32
+ Preorder { body, visited : DenseBitSet :: new_empty ( body. basic_blocks . len ( ) ) , worklist }
39
33
}
40
34
}
41
35
@@ -71,15 +65,11 @@ impl<'a, 'tcx> Iterator for Preorder<'a, 'tcx> {
71
65
}
72
66
73
67
fn size_hint ( & self ) -> ( usize , Option < usize > ) {
74
- // All the blocks, minus the number of blocks we've visited.
75
- let upper = self . body . basic_blocks . len ( ) - self . visited . count ( ) ;
68
+ // The worklist might be only things already visited.
69
+ let lower = 0 ;
76
70
77
- let lower = if self . root_is_start_block {
78
- // We will visit all remaining blocks exactly once.
79
- upper
80
- } else {
81
- self . worklist . len ( )
82
- } ;
71
+ // This is extremely loose, but it's not worth a popcnt loop to do better.
72
+ let upper = self . body . basic_blocks . len ( ) ;
83
73
84
74
( lower, Some ( upper) )
85
75
}
0 commit comments