Forward Hash::write_iN to Hash::write_uN - #73800
Conversation
|
r? @kennytm (rust_highfive has picked a reviewer for you, use r? to override) |
|
@bors r+ |
|
📌 Commit 4c14f9d has been approved by |
Forward Hash::write_iN to Hash::write_uN The `Hasher::write_iN()` methods should forward to `Hasher::write_uN()`, because some Hasher implementations implement only the `write_uN()` variants, with the expectation that `write_iN()` will use the same implementation. Most notably, this is the case for the [FxHasher](https://github.com/rust-lang/rustc-hash/blob/5e09ea0a1c7ab7e4f9e27771f5a0e5a36c58d1bb/src/lib.rs#L111) used by rustc itself. This used to be the case previously, but was broken in rust-lang#59982. As the PR description makes no mention of this particular change, I assume it was unintentional. In a local test, this mitigates the regression from rust-lang#73526 on at least one test-case (cc @cuviper), because we're no longer at the mercy of `FxHasher::write()` getting inlined to get reasonable performance.
commented
Jun 28, 2020
|
@bors retry rollup=never May have perf implications |
commented
Jun 28, 2020
|
May I think may have observable change in behaviour, not sure if that means this PR is acceptable or not... |
commented
Jun 28, 2020
|
In that sense, this is just reverting the observable change in #59982. |
commented
Jun 28, 2020
Not really. It was a change from self.write(&unsafe { mem::transmute::<_, [u8; 4]>(i) }) to self.write(&i.to_ne_bytes())In both cases the function called, the data types, and the values supplied were identical. A |
commented
Jun 28, 2020
|
Oh sorry, I see what you mean, I was looking at the wrong functions ^^ Ignore me. |
commented
Jun 29, 2020
It was accidentally rolled up anyway in #73838. |
The
Hasher::write_iN()methods should forward toHasher::write_uN(), because some Hasher implementations implement only thewrite_uN()variants, with the expectation thatwrite_iN()will use the same implementation. Most notably, this is the case for the FxHasher used by rustc itself.This used to be the case previously, but was broken in #59982. As the PR description makes no mention of this particular change, I assume it was unintentional.
In a local test, this mitigates the regression from #73526 on at least one test-case (cc @cuviper), because we're no longer at the mercy of
FxHasher::write()getting inlined to get reasonable performance.