about summary refs log tree commit diff
path: root/src/libcore/hash
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2020-02-07 11:53:07 +1100
committerNicholas Nethercote <nnethercote@mozilla.com>2020-02-21 10:11:35 +1100
commit100ff5a25666a1903113ecff0dc63ad84e5bdff7 (patch)
tree74c89ca9eef234c4270bcace1c06b18c2134d8d8 /src/libcore/hash
parent5e7af4669f80e5f682141f050193ab679afdb4b1 (diff)
downloadrust-100ff5a25666a1903113ecff0dc63ad84e5bdff7.tar.gz
rust-100ff5a25666a1903113ecff0dc63ad84e5bdff7.zip
Revert `u8to64_le` changes from #68914.
`SipHasher128`'s `u8to64_le` function was simplified in #68914.
Unfortunately, the new version is slower, because it introduces `memcpy`
calls with non-statically-known lengths.

This commit reverts the change, and adds an explanatory comment (which
is also added to `libcore/hash/sip.rs`). This barely affects
`SipHasher128`'s speed because it doesn't use `u8to64_le` much, but it
does result in `SipHasher128` once again being consistent with
`libcore/hash/sip.rs`.
Diffstat (limited to 'src/libcore/hash')
-rw-r--r--src/libcore/hash/sip.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libcore/hash/sip.rs b/src/libcore/hash/sip.rs
index 7ebe01e26dc..c4fbd9dbada 100644
--- a/src/libcore/hash/sip.rs
+++ b/src/libcore/hash/sip.rs
@@ -121,7 +121,9 @@ macro_rules! load_int_le {
     }};
 }
 
-/// Loads an u64 using up to 7 bytes of a byte slice.
+/// Loads a u64 using up to 7 bytes of a byte slice. It looks clumsy but the
+/// `copy_nonoverlapping` calls that occur (via `load_int_le!`) all have fixed
+/// sizes and avoid calling `memcpy`, which is good for speed.
 ///
 /// Unsafe because: unchecked indexing at start..start+len
 #[inline]