From a676dfa888b3d14abfa5d9b9a1045f8c1bde6793 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 28 Apr 2023 09:16:31 +1000 Subject: [PATCH] Remove `MemDecoder::read_byte`. It's just a synonym for `read_u8`. --- compiler/rustc_serialize/src/opaque.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_serialize/src/opaque.rs b/compiler/rustc_serialize/src/opaque.rs index 44d0cc8164d..0f6e4b329b8 100644 --- a/compiler/rustc_serialize/src/opaque.rs +++ b/compiler/rustc_serialize/src/opaque.rs @@ -504,19 +504,6 @@ impl<'a> MemDecoder<'a> { panic!("MemDecoder exhausted") } - #[inline] - fn read_byte(&mut self) -> u8 { - if self.current == self.end { - Self::decoder_exhausted(); - } - // SAFETY: This type guarantees current <= end, and we just checked current == end. - unsafe { - let byte = *self.current; - self.current = self.current.add(1); - byte - } - } - #[inline] fn read_array(&mut self) -> [u8; N] { self.read_raw_bytes(N).try_into().unwrap() @@ -586,7 +573,15 @@ impl<'a> Decoder for MemDecoder<'a> { #[inline] fn read_u8(&mut self) -> u8 { - self.read_byte() + if self.current == self.end { + Self::decoder_exhausted(); + } + // SAFETY: This type guarantees current <= end, and we just checked current == end. + unsafe { + let byte = *self.current; + self.current = self.current.add(1); + byte + } } #[inline]