]> git.lizzy.rs Git - rust.git/commit - src/tools/rust-analyzer
Auto merge of #93671 - Kobzol:stable-hash-const, r=the8472
authorbors <bors@rust-lang.org>
Sat, 12 Feb 2022 02:05:11 +0000 (02:05 +0000)
committerbors <bors@rust-lang.org>
Sat, 12 Feb 2022 02:05:11 +0000 (02:05 +0000)
commitfc323035ac49b8d834fc2a0f580af8fd45e90b30
tree3f21d01d0e1ad8c8313510c18e4fce71472a11b7
parentf19851069efd6ee1fe899a469f08ad2d66e76050
parent5fc2e5623bd9dc53daf144626c9da2feb9daf682
Auto merge of #93671 - Kobzol:stable-hash-const, r=the8472

Use const generics in SipHasher128's short_write

This was proposed by `@michaelwoerister` [here](https://github.com/rust-lang/rust/pull/93615#discussion_r799485554).
A few comments:
1) I tried to pass `&[u8; LEN]` instead of `[u8; LEN]`. Locally, it resulted in small icount regressions (about 0.5 %). When passing by value, there were no regressions (and no improvements).
2) I wonder if we should use `to_ne_bytes()` in `SipHasher128` to keep it generic and only use `to_le_bytes()` in `StableHasher`. However, currently `SipHasher128` is only used in `StableHasher` and the `short_write` method was private, so I couldn't use it directly from `StableHasher`. Using `to_le()` in the `StableHasher` was breaking this abstraction boundary before slightly.

```rust
debug_assert!(LEN <= 8);
```
This could be done at compile time, but actually I think that now we can remove this assert altogether.

r? `@the8472`