about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-01-02 09:52:26 +0000
committerbors <bors@rust-lang.org>2021-01-02 09:52:26 +0000
commit929f66af9bf587383ed6010403e738e79dfac0d6 (patch)
tree5e2e74e91f1eb6ba9f4a4d119c79d6c011abd611 /compiler/rustc_data_structures/src
parent5986dd878f3e432025eb1946149e3241d3998b1b (diff)
parentbe79f493fb310b3a6b01ceada32713813bb12a91 (diff)
downloadrust-929f66af9bf587383ed6010403e738e79dfac0d6.tar.gz
rust-929f66af9bf587383ed6010403e738e79dfac0d6.zip
Auto merge of #80115 - tgnottingham:specialize_opaque_u8_sequences, r=oli-obk
rustc_serialize: specialize opaque encoding and decoding of some u8 sequences

This specializes encoding and decoding of some contiguous u8 sequences to use a more efficient implementation. The default implementations process each u8 individually, but that isn't necessary for the opaque encoder and decoder. The opaque encoding for u8s is a no-op, so we can just copy entire sequences as-is, rather than process them byte by byte.

This also changes some encode and decode implementations for contiguous sequences to forward to the slice and vector implementations, so that they can take advantage of the new specialization when applicable.
Diffstat (limited to 'compiler/rustc_data_structures/src')
-rw-r--r--compiler/rustc_data_structures/src/fingerprint.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_data_structures/src/fingerprint.rs b/compiler/rustc_data_structures/src/fingerprint.rs
index 01efcaf6f44..8afe94ac8db 100644
--- a/compiler/rustc_data_structures/src/fingerprint.rs
+++ b/compiler/rustc_data_structures/src/fingerprint.rs
@@ -4,7 +4,7 @@ use rustc_serialize::{
     Decodable, Encodable,
 };
 use std::hash::{Hash, Hasher};
-use std::mem;
+use std::mem::{self, MaybeUninit};
 
 #[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Copy)]
 pub struct Fingerprint(u64, u64);
@@ -61,7 +61,7 @@ impl Fingerprint {
     }
 
     pub fn decode_opaque(decoder: &mut opaque::Decoder<'_>) -> Result<Fingerprint, String> {
-        let mut bytes = [0; 16];
+        let mut bytes: [MaybeUninit<u8>; 16] = MaybeUninit::uninit_array();
 
         decoder.read_raw_bytes(&mut bytes)?;