Skip to content

Commit 1b47769

Browse files
authored
Rollup merge of #109287 - scottmcm:hash-slice-size-of-val, r=oli-obk
Use `size_of_val` instead of manual calculation Very minor thing that I happened to notice in passing, but it's both shorter and [means it gets `mul nsw`](https://rust.godbolt.org/z/Y9KxYETv5), so why not.
2 parents af2d0ef + 7f9907f commit 1b47769

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/src/hash/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ mod impls {
834834

835835
#[inline]
836836
fn hash_slice<H: ~const Hasher>(data: &[$ty], state: &mut H) {
837-
let newlen = data.len() * mem::size_of::<$ty>();
837+
let newlen = mem::size_of_val(data);
838838
let ptr = data.as_ptr() as *const u8;
839839
// SAFETY: `ptr` is valid and aligned, as this macro is only used
840840
// for numeric primitives which have no padding. The new slice only

0 commit comments

Comments
 (0)