From 100ff5a25666a1903113ecff0dc63ad84e5bdff7 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 7 Feb 2020 11:53:07 +1100 Subject: 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`. --- src/libcore/hash/sip.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/libcore') 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] -- cgit 1.4.1-3-g733a5