Skip to content

Commit 12a68e6

Browse files
committed
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).
1 parent 004c4b4 commit 12a68e6

File tree

1 file changed

+4
-0
lines changed
  • src/librustc_data_structures

1 file changed

+4
-0
lines changed

src/librustc_data_structures/fnv.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ pub fn FnvHashSet<V: Hash + Eq>() -> FnvHashSet<V> {
3535
pub struct FnvHasher(u64);
3636

3737
impl Default for FnvHasher {
38+
#[inline]
3839
fn default() -> FnvHasher { FnvHasher(0xcbf29ce484222325) }
3940
}
4041

4142
impl Hasher for FnvHasher {
43+
#[inline]
4244
fn write(&mut self, bytes: &[u8]) {
4345
let FnvHasher(mut hash) = *self;
4446
for byte in bytes {
@@ -47,5 +49,7 @@ impl Hasher for FnvHasher {
4749
}
4850
*self = FnvHasher(hash);
4951
}
52+
53+
#[inline]
5054
fn finish(&self) -> u64 { self.0 }
5155
}

0 commit comments

Comments
 (0)