Skip to content

Commit

Permalink
Rollup merge of #68691 - nnethercote:rm-RefCell-from-ObligationForest…
Browse files Browse the repository at this point in the history
…, 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
  • Loading branch information
Dylan-DPC authored Feb 6, 2020
2 parents 1f8df25 + 6ad725e commit a1478b7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/librustc_data_structures/obligation_forest/mod.rs
Original file line number Diff line number Diff line change
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 a1478b7

Please sign in to comment.