Skip to content

Commit

Permalink
Remove MemDecoder::read_byte.
Browse files Browse the repository at this point in the history
It's just a synonym for `read_u8`.
  • Loading branch information
nnethercote committed Apr 28, 2023
1 parent 7a16d25 commit a676dfa
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions compiler/rustc_serialize/src/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<const N: usize>(&mut self) -> [u8; N] {
self.read_raw_bytes(N).try_into().unwrap()
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit a676dfa

Please sign in to comment.