diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-06-28 08:30:29 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-28 08:30:29 -0700 |
| commit | 95da53f7fd7434f2cb13b069d4e26b961879cf65 (patch) | |
| tree | 4449e0819fbcf482324adfa50a968ff7a39e0d0c /src/libcore | |
| parent | 2c1b7329611f0310ed18dd9bb6dea99cd42302c1 (diff) | |
| parent | 4c14f9d110478edcb2d0c3e1cda73937fc3b3d6e (diff) | |
| download | rust-95da53f7fd7434f2cb13b069d4e26b961879cf65.tar.gz rust-95da53f7fd7434f2cb13b069d4e26b961879cf65.zip | |
Rollup merge of #73800 - nikic:hash_i, r=kennytm
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 #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.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/hash/mod.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index d80101753cb..6abe19dc155 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -333,31 +333,31 @@ pub trait Hasher { #[inline] #[stable(feature = "hasher_write", since = "1.3.0")] fn write_i16(&mut self, i: i16) { - self.write(&i.to_ne_bytes()) + self.write_u16(i as u16) } /// Writes a single `i32` into this hasher. #[inline] #[stable(feature = "hasher_write", since = "1.3.0")] fn write_i32(&mut self, i: i32) { - self.write(&i.to_ne_bytes()) + self.write_u32(i as u32) } /// Writes a single `i64` into this hasher. #[inline] #[stable(feature = "hasher_write", since = "1.3.0")] fn write_i64(&mut self, i: i64) { - self.write(&i.to_ne_bytes()) + self.write_u64(i as u64) } /// Writes a single `i128` into this hasher. #[inline] #[stable(feature = "i128", since = "1.26.0")] fn write_i128(&mut self, i: i128) { - self.write(&i.to_ne_bytes()) + self.write_u128(i as u128) } /// Writes a single `isize` into this hasher. #[inline] #[stable(feature = "hasher_write", since = "1.3.0")] fn write_isize(&mut self, i: isize) { - self.write(&i.to_ne_bytes()) + self.write_usize(i as usize) } } |
