]> git.lizzy.rs Git - rust.git/commitdiff
nit: cache crate-hash for next time
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 12 May 2016 15:37:08 +0000 (11:37 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Wed, 18 May 2016 14:11:36 +0000 (10:11 -0400)
src/librustc_incremental/persist/hash.rs

index c36b9ed0d26a3246eb6f596c0be85408fdc1fa19..b729f25b873d4f05ec8df2b45e7239c4cb02fa7f 100644 (file)
@@ -86,6 +86,11 @@ fn metadata_hash(&mut self, def_id: DefId) -> u64 {
             // krate; in that case, we just use the krate's overall hash
             if let Some(&hash) = self.crate_hashes.get(&def_id.krate) {
                 debug!("metadata_hash: def_id={:?} crate_hash={:?}", def_id, hash);
+
+                // micro-"optimization": avoid a cache miss if we ask
+                // for metadata from this particular def-id again.
+                self.item_metadata_hashes.insert(def_id, hash.as_u64());
+
                 return hash.as_u64();
             }