Address review comments.

This commit is contained in:
Nicholas Nethercote 2022-01-20 09:59:30 +11:00
parent 416399dc10
commit 37fbd91eb5
5 changed files with 9 additions and 11 deletions

View File

@ -475,7 +475,7 @@ macro_rules! implement_ty_decoder {
} }
#[inline] #[inline]
fn read_raw_bytes_into(&mut self, bytes: &mut [u8]) -> () { fn read_raw_bytes_into(&mut self, bytes: &mut [u8]) {
self.opaque.read_raw_bytes_into(bytes) self.opaque.read_raw_bytes_into(bytes)
} }
} }

View File

@ -2792,9 +2792,9 @@ impl<T, R> InternIteratorElement<T, R> for T {
) -> Self::Output { ) -> Self::Output {
// This code is hot enough that it's worth specializing for the most // This code is hot enough that it's worth specializing for the most
// common length lists, to avoid the overhead of `SmallVec` creation. // common length lists, to avoid the overhead of `SmallVec` creation.
// Lengths 0, 1, and 2 typically account for ~95% of cases. We assume // Lengths 0, 1, and 2 typically account for ~95% of cases. If
// that if the upper and lower bounds from `size_hint` agree they are // `size_hint` is incorrect a panic will occur via an `unwrap` or an
// correct. // `assert`.
match iter.size_hint() { match iter.size_hint() {
(0, Some(0)) => { (0, Some(0)) => {
assert!(iter.next().is_none()); assert!(iter.next().is_none());
@ -2835,9 +2835,10 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> {
) -> Self::Output { ) -> Self::Output {
// This code is hot enough that it's worth specializing for the most // This code is hot enough that it's worth specializing for the most
// common length lists, to avoid the overhead of `SmallVec` creation. // common length lists, to avoid the overhead of `SmallVec` creation.
// Lengths 0, 1, and 2 typically account for ~95% of cases. We assume // Lengths 0, 1, and 2 typically account for ~95% of cases. If
// that if the upper and lower bounds from `size_hint` agree they are // `size_hint` is incorrect a panic will occur via an `unwrap` or an
// correct. // `assert`, unless a failure happens first, in which case the result
// will be an error anyway.
Ok(match iter.size_hint() { Ok(match iter.size_hint() {
(0, Some(0)) => { (0, Some(0)) => {
assert!(iter.next().is_none()); assert!(iter.next().is_none());

View File

@ -142,7 +142,6 @@ impl<'a, K: DepKind + Decodable<opaque::Decoder<'a>>> Decodable<opaque::Decoder<
let end = edge_list_data.len().try_into().unwrap(); let end = edge_list_data.len().try_into().unwrap();
let _i: SerializedDepNodeIndex = edge_list_indices.push((start, end)); let _i: SerializedDepNodeIndex = edge_list_indices.push((start, end));
debug_assert_eq!(_i.index(), _index); debug_assert_eq!(_i.index(), _index);
()
}) })
}) })
}); });

View File

@ -2296,7 +2296,6 @@ impl crate::Decoder for Decoder {
for c in s.iter_mut() { for c in s.iter_mut() {
*c = self.read_u8(); *c = self.read_u8();
} }
()
} }
fn read_enum<T, F>(&mut self, f: F) -> T fn read_enum<T, F>(&mut self, f: F) -> T

View File

@ -676,11 +676,10 @@ impl<'a> serialize::Decoder for Decoder<'a> {
} }
#[inline] #[inline]
fn read_raw_bytes_into(&mut self, s: &mut [u8]) -> () { fn read_raw_bytes_into(&mut self, s: &mut [u8]) {
let start = self.position; let start = self.position;
self.position += s.len(); self.position += s.len();
s.copy_from_slice(&self.data[start..self.position]); s.copy_from_slice(&self.data[start..self.position]);
()
} }
} }