@@ -149,8 +149,8 @@ pub struct ObligationForest<O: ForestObligation> {
149
149
/// comments in `process_obligation` for details.
150
150
active_cache : FxHashMap < O :: CacheKey , usize > ,
151
151
152
- /// A vector reused in compress(), to avoid allocating new vectors.
153
- node_rewrites : Vec < usize > ,
152
+ /// A vector reused in compress() and find_cycles_from_node() , to avoid allocating new vectors.
153
+ reused_node_vec : Vec < usize > ,
154
154
155
155
obligation_tree_id_generator : ObligationTreeIdGenerator ,
156
156
@@ -289,7 +289,7 @@ impl<O: ForestObligation> ObligationForest<O> {
289
289
nodes : vec ! [ ] ,
290
290
done_cache : Default :: default ( ) ,
291
291
active_cache : Default :: default ( ) ,
292
- node_rewrites : vec ! [ ] ,
292
+ reused_node_vec : vec ! [ ] ,
293
293
obligation_tree_id_generator : ( 0 ..) . map ( ObligationTreeId ) ,
294
294
error_cache : Default :: default ( ) ,
295
295
}
@@ -544,12 +544,11 @@ impl<O: ForestObligation> ObligationForest<O> {
544
544
545
545
/// Report cycles between all `Success` nodes, and convert all `Success`
546
546
/// nodes to `Done`. This must be called after `mark_successes`.
547
- fn process_cycles < P > ( & self , processor : & mut P )
547
+ fn process_cycles < P > ( & mut self , processor : & mut P )
548
548
where
549
549
P : ObligationProcessor < Obligation = O > ,
550
550
{
551
- let mut stack = vec ! [ ] ;
552
-
551
+ let mut stack = std:: mem:: take ( & mut self . reused_node_vec ) ;
553
552
for ( index, node) in self . nodes . iter ( ) . enumerate ( ) {
554
553
// For some benchmarks this state test is extremely hot. It's a win
555
554
// to handle the no-op cases immediately to avoid the cost of the
@@ -560,6 +559,7 @@ impl<O: ForestObligation> ObligationForest<O> {
560
559
}
561
560
562
561
debug_assert ! ( stack. is_empty( ) ) ;
562
+ self . reused_node_vec = stack;
563
563
}
564
564
565
565
fn find_cycles_from_node < P > ( & self , stack : & mut Vec < usize > , processor : & mut P , index : usize )
@@ -594,7 +594,7 @@ impl<O: ForestObligation> ObligationForest<O> {
594
594
#[ inline( never) ]
595
595
fn compress ( & mut self , do_completed : DoCompleted ) -> Option < Vec < O > > {
596
596
let orig_nodes_len = self . nodes . len ( ) ;
597
- let mut node_rewrites: Vec < _ > = std:: mem:: take ( & mut self . node_rewrites ) ;
597
+ let mut node_rewrites: Vec < _ > = std:: mem:: take ( & mut self . reused_node_vec ) ;
598
598
debug_assert ! ( node_rewrites. is_empty( ) ) ;
599
599
node_rewrites. extend ( 0 ..orig_nodes_len) ;
600
600
let mut dead_nodes = 0 ;
@@ -655,7 +655,7 @@ impl<O: ForestObligation> ObligationForest<O> {
655
655
}
656
656
657
657
node_rewrites. truncate ( 0 ) ;
658
- self . node_rewrites = node_rewrites;
658
+ self . reused_node_vec = node_rewrites;
659
659
660
660
if do_completed == DoCompleted :: Yes { Some ( removed_done_obligations) } else { None }
661
661
}
0 commit comments