From 12a68e6af31a32c52785298f036543caa96d24d3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 6 Feb 2016 22:56:25 -0800 Subject: [PATCH] rustc: Ensure FNV hashing is inlined across crates Right now the primary hashing algorithm of the compiler isn't actually inlined across crates, meaning that it may be missing out on some crucial optimizations in a few places (perhaps unrolling smaller loops, etc). This commit made the hashing function disappear from a profiled version of the compiler, but that's likely because it was just inlined elsewhere. When compiling winapi, however, this decreased compile time from 18.3 to 17.8 seconds (a 3% improvement). --- src/librustc_data_structures/fnv.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustc_data_structures/fnv.rs b/src/librustc_data_structures/fnv.rs index 6f4dc28e12221..da5f9f2089200 100644 --- a/src/librustc_data_structures/fnv.rs +++ b/src/librustc_data_structures/fnv.rs @@ -35,10 +35,12 @@ pub fn FnvHashSet() -> FnvHashSet { pub struct FnvHasher(u64); impl Default for FnvHasher { + #[inline] fn default() -> FnvHasher { FnvHasher(0xcbf29ce484222325) } } impl Hasher for FnvHasher { + #[inline] fn write(&mut self, bytes: &[u8]) { let FnvHasher(mut hash) = *self; for byte in bytes { @@ -47,5 +49,7 @@ impl Hasher for FnvHasher { } *self = FnvHasher(hash); } + + #[inline] fn finish(&self) -> u64 { self.0 } }