diff options
| author | bors <bors@rust-lang.org> | 2015-05-03 20:55:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-05-03 20:55:59 +0000 |
| commit | 796be61e9099a440c90f35636ec6a41f89f3639f (patch) | |
| tree | eca28d056bcf4ef5c7f66ae24f198ca7b49a73e7 | |
| parent | 6b3d66b04f9ade6b3a46db4eb188e7397b44117a (diff) | |
| parent | f4176b52d3817b93570a73e2768736276d76ebf5 (diff) | |
Auto merge of #25070 - dotdash:inline_hash, r=alexcrichton
Since the hashmap and its hasher are implemented in different crates, we currently can't benefit from inlining, which means that especially for small, fixed size keys, there is a huge overhead in hash calculations, because the compiler can't apply optimizations that only apply for these keys. Fixes the brainfuck benchmark in #24014.
| -rw-r--r-- | src/libcore/hash/sip.rs | 3 | ||||
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs index be419e2cdad..a92b72e0f00 100644 --- a/src/libcore/hash/sip.rs +++ b/src/libcore/hash/sip.rs @@ -111,6 +111,7 @@ impl SipHasher { state } + #[inline] fn reset(&mut self) { self.length = 0; self.v0 = self.k0 ^ 0x736f6d6570736575; @@ -120,6 +121,7 @@ impl SipHasher { self.ntail = 0; } + #[inline] fn write(&mut self, msg: &[u8]) { let length = msg.len(); self.length += length; @@ -173,6 +175,7 @@ impl Hasher for SipHasher { self.write(msg) } + #[inline] fn finish(&self) -> u64 { let mut v0 = self.v0; let mut v1 = self.v1; diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index ec130e8233a..f82c1653be1 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1600,6 +1600,7 @@ impl RandomState { reason = "hashing an hash maps may be altered")] impl HashState for RandomState { type Hasher = SipHasher; + #[inline] fn hasher(&self) -> SipHasher { SipHasher::new_with_keys(self.k0, self.k1) } |
