Skip to content

Commit

Permalink
Rollup merge of #50598 - whitfin:unnecessary-mut-borrow, r=michaelwoe…
Browse files Browse the repository at this point in the history
…rister

Remove unnecessary mutable borrow and resizing in DepGraph::serialize

I might be mistaken, but I noticed this whilst in this file for something else. It appears that this mutable borrow is unnecessary and since it's locking it should be removed. The resizing looks redundant since nothing additional is added to the fingerprints in this function, so that can also be removed.
  • Loading branch information
alexcrichton committed May 10, 2018
2 parents 8b5f692 + ae3feff commit 74e731f
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,15 +523,9 @@ impl DepGraph {
}

pub fn serialize(&self) -> SerializedDepGraph {
let mut fingerprints = self.fingerprints.borrow_mut();
let current_dep_graph = self.data.as_ref().unwrap().current.borrow();

// Make sure we don't run out of bounds below.
if current_dep_graph.nodes.len() > fingerprints.len() {
fingerprints.resize(current_dep_graph.nodes.len(), Fingerprint::ZERO);
}

let fingerprints = fingerprints.clone().convert_index_type();
let fingerprints = self.fingerprints.borrow().clone().convert_index_type();
let nodes = current_dep_graph.nodes.clone().convert_index_type();

let total_edge_count: usize = current_dep_graph.edges.iter()
Expand Down

0 comments on commit 74e731f

Please sign in to comment.