diff options
| author | Peter Hrvola <peter.hrvola@hotmail.com> | 2018-02-23 20:18:38 +0100 |
|---|---|---|
| committer | Peter Hrvola <peter.hrvola@hotmail.com> | 2018-03-14 00:10:57 +0100 |
| commit | 2f2e17341c171c847c201516bec9bf2234704000 (patch) | |
| tree | 14fc9ae6b4627d382a2dd2e8bb4915c68bd31192 /src | |
| parent | 063deba92e44809125a433ca6e6c1ad0993313bf (diff) | |
| download | rust-2f2e17341c171c847c201516bec9bf2234704000.tar.gz rust-2f2e17341c171c847c201516bec9bf2234704000.zip | |
Speed up SVH computation by using Fingerprint::combine()
Fix #47297 r? @michaelwoerister
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/hir/map/collector.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 99b1e5783e0..e6f95fb99ea 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -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; @@ -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(); |
