Skip to content

Commit a1478b7

Browse files
authored
Rollup merge of #68691 - nnethercote:rm-RefCell-from-ObligationForest, r=nikomatsakis
Remove `RefCell` usage from `ObligationForest`. It's not needed. This doesn't affect performance, it just simplifies the code a little. r? @nikomatsakis
2 parents 1f8df25 + 6ad725e commit a1478b7

File tree

1 file changed

+5
-5
lines changed
  • src/librustc_data_structures/obligation_forest

1 file changed

+5
-5
lines changed

src/librustc_data_structures/obligation_forest/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
7575
use crate::fx::{FxHashMap, FxHashSet};
7676

77-
use std::cell::{Cell, RefCell};
77+
use std::cell::Cell;
7878
use std::collections::hash_map::Entry;
7979
use std::fmt::Debug;
8080
use std::hash;
@@ -146,7 +146,7 @@ pub struct ObligationForest<O: ForestObligation> {
146146
active_cache: FxHashMap<O::Predicate, usize>,
147147

148148
/// A vector reused in compress(), to avoid allocating new vectors.
149-
node_rewrites: RefCell<Vec<usize>>,
149+
node_rewrites: Vec<usize>,
150150

151151
obligation_tree_id_generator: ObligationTreeIdGenerator,
152152

@@ -285,7 +285,7 @@ impl<O: ForestObligation> ObligationForest<O> {
285285
nodes: vec![],
286286
done_cache: Default::default(),
287287
active_cache: Default::default(),
288-
node_rewrites: RefCell::new(vec![]),
288+
node_rewrites: vec![],
289289
obligation_tree_id_generator: (0..).map(ObligationTreeId),
290290
error_cache: Default::default(),
291291
}
@@ -590,7 +590,7 @@ impl<O: ForestObligation> ObligationForest<O> {
590590
#[inline(never)]
591591
fn compress(&mut self, do_completed: DoCompleted) -> Option<Vec<O>> {
592592
let orig_nodes_len = self.nodes.len();
593-
let mut node_rewrites: Vec<_> = self.node_rewrites.replace(vec![]);
593+
let mut node_rewrites: Vec<_> = std::mem::take(&mut self.node_rewrites);
594594
debug_assert!(node_rewrites.is_empty());
595595
node_rewrites.extend(0..orig_nodes_len);
596596
let mut dead_nodes = 0;
@@ -651,7 +651,7 @@ impl<O: ForestObligation> ObligationForest<O> {
651651
}
652652

653653
node_rewrites.truncate(0);
654-
self.node_rewrites.replace(node_rewrites);
654+
self.node_rewrites = node_rewrites;
655655

656656
if do_completed == DoCompleted::Yes { Some(removed_done_obligations) } else { None }
657657
}

0 commit comments

Comments
 (0)