|
74 | 74 |
|
75 | 75 | use crate::fx::{FxHashMap, FxHashSet};
|
76 | 76 |
|
77 |
| -use std::cell::{Cell, RefCell}; |
| 77 | +use std::cell::Cell; |
78 | 78 | use std::collections::hash_map::Entry;
|
79 | 79 | use std::fmt::Debug;
|
80 | 80 | use std::hash;
|
81 | 81 | use std::marker::PhantomData;
|
| 82 | +use std::mem; |
82 | 83 |
|
83 | 84 | mod graphviz;
|
84 | 85 |
|
@@ -143,7 +144,7 @@ pub struct ObligationForest<O: ForestObligation> {
|
143 | 144 | active_cache: FxHashMap<O::Predicate, Option<usize>>,
|
144 | 145 |
|
145 | 146 | /// A vector reused in compress(), to avoid allocating new vectors.
|
146 |
| - node_rewrites: RefCell<Vec<usize>>, |
| 147 | + node_rewrites: Vec<usize>, |
147 | 148 |
|
148 | 149 | obligation_tree_id_generator: ObligationTreeIdGenerator,
|
149 | 150 |
|
@@ -281,7 +282,7 @@ impl<O: ForestObligation> ObligationForest<O> {
|
281 | 282 | ObligationForest {
|
282 | 283 | nodes: vec![],
|
283 | 284 | active_cache: Default::default(),
|
284 |
| - node_rewrites: RefCell::new(vec![]), |
| 285 | + node_rewrites: vec![], |
285 | 286 | obligation_tree_id_generator: (0..).map(ObligationTreeId),
|
286 | 287 | error_cache: Default::default(),
|
287 | 288 | }
|
@@ -587,7 +588,7 @@ impl<O: ForestObligation> ObligationForest<O> {
|
587 | 588 | fn compress(&mut self, do_completed: DoCompleted) -> Option<Vec<O>> {
|
588 | 589 | let orig_nodes_len = self.nodes.len();
|
589 | 590 | let remove_node_marker = orig_nodes_len + 1;
|
590 |
| - let mut node_rewrites: Vec<_> = self.node_rewrites.replace(vec![]); |
| 591 | + let mut node_rewrites: Vec<_> = mem::take(&mut self.node_rewrites); |
591 | 592 | debug_assert!(node_rewrites.is_empty());
|
592 | 593 | node_rewrites.extend(0..orig_nodes_len);
|
593 | 594 | let mut dead_nodes = 0;
|
@@ -636,8 +637,8 @@ impl<O: ForestObligation> ObligationForest<O> {
|
636 | 637 | self.apply_rewrites(&node_rewrites);
|
637 | 638 | }
|
638 | 639 |
|
639 |
| - node_rewrites.truncate(0); |
640 |
| - self.node_rewrites.replace(node_rewrites); |
| 640 | + node_rewrites.clear(); |
| 641 | + self.node_rewrites = node_rewrites; |
641 | 642 |
|
642 | 643 | if do_completed == DoCompleted::Yes { Some(removed_done_obligations) } else { None }
|
643 | 644 | }
|
|
0 commit comments