Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove RefCell usage from ObligationForest.
It's not needed.
  • Loading branch information
nnethercote committed Feb 6, 2020
1 parent 002287d commit 6ad725e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/librustc_data_structures/obligation_forest/mod.rs
Expand Up @@ -74,7 +74,7 @@

use crate::fx::{FxHashMap, FxHashSet};

use std::cell::{Cell, RefCell};
use std::cell::Cell;
use std::collections::hash_map::Entry;
use std::fmt::Debug;
use std::hash;
Expand Down Expand Up @@ -146,7 +146,7 @@ pub struct ObligationForest<O: ForestObligation> {
active_cache: FxHashMap<O::Predicate, usize>,

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

obligation_tree_id_generator: ObligationTreeIdGenerator,

Expand Down Expand Up @@ -285,7 +285,7 @@ impl<O: ForestObligation> ObligationForest<O> {
nodes: vec![],
done_cache: Default::default(),
active_cache: Default::default(),
node_rewrites: RefCell::new(vec![]),
node_rewrites: vec![],
obligation_tree_id_generator: (0..).map(ObligationTreeId),
error_cache: Default::default(),
}
Expand Down Expand Up @@ -590,7 +590,7 @@ impl<O: ForestObligation> ObligationForest<O> {
#[inline(never)]
fn compress(&mut self, do_completed: DoCompleted) -> Option<Vec<O>> {
let orig_nodes_len = self.nodes.len();
let mut node_rewrites: Vec<_> = self.node_rewrites.replace(vec![]);
let mut node_rewrites: Vec<_> = std::mem::take(&mut self.node_rewrites);
debug_assert!(node_rewrites.is_empty());
node_rewrites.extend(0..orig_nodes_len);
let mut dead_nodes = 0;
Expand Down Expand Up @@ -651,7 +651,7 @@ impl<O: ForestObligation> ObligationForest<O> {
}

node_rewrites.truncate(0);
self.node_rewrites.replace(node_rewrites);
self.node_rewrites = node_rewrites;

if do_completed == DoCompleted::Yes { Some(removed_done_obligations) } else { None }
}
Expand Down

0 comments on commit 6ad725e

Please sign in to comment.