Skip to content

Commit

Permalink
Speed up SVH computation by using Fingerprint::combine()
Browse files Browse the repository at this point in the history
  • Loading branch information
hrvolapeter committed Mar 13, 2018
1 parent 063deba commit 2f2e173
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/librustc/hir/map/collector.rs
Expand Up @@ -13,6 +13,7 @@ use dep_graph::{DepGraph, DepKind, DepNodeIndex};
use hir::def_id::{LOCAL_CRATE, CrateNum};
use hir::intravisit::{Visitor, NestedVisitorMap};
use hir::svh::Svh;
use ich::Fingerprint;
use middle::cstore::CrateStore;
use session::CrateDisambiguator;
use std::iter::repeat;
Expand Down Expand Up @@ -121,21 +122,24 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
collector
}

pub(super) fn finalize_and_compute_crate_hash(self,
pub(super) fn finalize_and_compute_crate_hash(mut self,
crate_disambiguator: CrateDisambiguator,
cstore: &CrateStore,
codemap: &CodeMap,
commandline_args_hash: u64)
-> (Vec<MapEntry<'hir>>, Svh) {
let mut node_hashes: Vec<_> = self
self
.hir_body_nodes
.iter()
.map(|&(def_path_hash, dep_node_index)| {
(def_path_hash, self.dep_graph.fingerprint_of(dep_node_index))
})
.collect();
.sort_unstable_by(|&(ref d1, _), &(ref d2, _)| d1.cmp(d2));

node_hashes.sort_unstable_by(|&(ref d1, _), &(ref d2, _)| d1.cmp(d2));
let node_hashes = self
.hir_body_nodes
.iter()
.fold(Fingerprint::ZERO, |fingerprint , &(def_path_hash, dep_node_index)| {
fingerprint.combine(
def_path_hash.0.combine(self.dep_graph.fingerprint_of(dep_node_index))
)
});

let mut upstream_crates: Vec<_> = cstore.crates_untracked().iter().map(|&cnum| {
let name = cstore.crate_name_untracked(cnum).as_str();
Expand Down

0 comments on commit 2f2e173

Please sign in to comment.