From b2f72394ce4755cf145afc116077b32aaaed61b1 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 20 Dec 2017 14:06:11 +0100 Subject: [PATCH] incr.comp.: Replace Fingerprint::zero() with a constant. --- src/librustc/dep_graph/dep_node.rs | 4 ++-- src/librustc/dep_graph/graph.rs | 12 ++++++------ src/librustc/ich/fingerprint.rs | 6 ++---- src/librustc_metadata/decoder.rs | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 1f65df288ad..29839bb565b 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -279,7 +279,7 @@ macro_rules! define_dep_nodes { DepNode { kind: DepKind::$variant, - hash: Fingerprint::zero(), + hash: Fingerprint::ZERO, } } )* @@ -308,7 +308,7 @@ macro_rules! define_dep_nodes { assert!(!kind.has_params()); DepNode { kind, - hash: Fingerprint::zero(), + hash: Fingerprint::ZERO, } } diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index 5fa0cedfe74..7acb466e9f3 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -97,7 +97,7 @@ impl DepGraph { // Pre-allocate the fingerprints array. We over-allocate a little so // that we hopefully don't have to re-allocate during this compilation // session. - let fingerprints = IndexVec::from_elem_n(Fingerprint::zero(), + let fingerprints = IndexVec::from_elem_n(Fingerprint::ZERO, (prev_graph.node_count() * 115) / 100); DepGraph { data: Some(Rc::new(DepGraphData { @@ -236,10 +236,10 @@ impl DepGraph { let mut fingerprints = self.fingerprints.borrow_mut(); if dep_node_index.index() >= fingerprints.len() { - fingerprints.resize(dep_node_index.index() + 1, Fingerprint::zero()); + fingerprints.resize(dep_node_index.index() + 1, Fingerprint::ZERO); } - debug_assert!(fingerprints[dep_node_index] == Fingerprint::zero(), + debug_assert!(fingerprints[dep_node_index] == Fingerprint::ZERO, "DepGraph::with_task() - Duplicate fingerprint \ insertion for {:?}", key); fingerprints[dep_node_index] = current_fingerprint; @@ -451,7 +451,7 @@ impl DepGraph { // 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()); + fingerprints.resize(current_dep_graph.nodes.len(), Fingerprint::ZERO); } let nodes: IndexVec<_, (DepNode, Fingerprint)> = @@ -644,10 +644,10 @@ impl DepGraph { let mut fingerprints = self.fingerprints.borrow_mut(); if dep_node_index.index() >= fingerprints.len() { - fingerprints.resize(dep_node_index.index() + 1, Fingerprint::zero()); + fingerprints.resize(dep_node_index.index() + 1, Fingerprint::ZERO); } - debug_assert!(fingerprints[dep_node_index] == Fingerprint::zero(), + debug_assert!(fingerprints[dep_node_index] == Fingerprint::ZERO, "DepGraph::try_mark_green() - Duplicate fingerprint \ insertion for {:?}", dep_node); diff --git a/src/librustc/ich/fingerprint.rs b/src/librustc/ich/fingerprint.rs index 3d089d8e75f..dc7b9dbe2ef 100644 --- a/src/librustc/ich/fingerprint.rs +++ b/src/librustc/ich/fingerprint.rs @@ -14,10 +14,8 @@ use rustc_data_structures::stable_hasher; pub struct Fingerprint(u64, u64); impl Fingerprint { - #[inline] - pub fn zero() -> Fingerprint { - Fingerprint(0, 0) - } + + pub const ZERO: Fingerprint = Fingerprint(0, 0); #[inline] pub fn from_smaller_hash(hash: u64) -> Fingerprint { diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 49a017535ff..2e2bde5dad5 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -781,7 +781,7 @@ impl<'a, 'tcx> CrateMetadata { } else { ExternBodyNestedBodies { nested_bodies: Rc::new(BTreeMap::new()), - fingerprint: Fingerprint::zero(), + fingerprint: Fingerprint::ZERO, } } }