Move attrs to stmts

This commit is contained in:
0xd4d 2020-03-20 05:49:36 +01:00
parent 5a76f7d1b2
commit 2098b49c87
1 changed files with 2 additions and 2 deletions

View File

@ -629,11 +629,11 @@ impl<'a> Decoder<'a> {
}
#[cfg_attr(has_must_use, must_use)]
#[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))]
pub(self) fn read_u16(&mut self) -> usize {
unsafe {
let data_ptr = self.data_ptr;
if data_ptr.offset(1) < self.max_data_ptr {
#[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))]
let result = u16::from_le(ptr::read_unaligned(data_ptr as *const u16)) as usize;
self.data_ptr = data_ptr.offset(2);
result
@ -645,7 +645,6 @@ impl<'a> Decoder<'a> {
}
#[cfg_attr(has_must_use, must_use)]
#[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))]
pub(self) fn read_u32(&mut self) -> usize {
// What I really wanted to do was: (this saves one instruction)
// const N: isize = 4;
@ -661,6 +660,7 @@ impl<'a> Decoder<'a> {
unsafe {
let data_ptr = self.data_ptr;
if data_ptr.offset(3) < self.max_data_ptr {
#[cfg_attr(feature = "cargo-clippy", allow(clippy::cast_ptr_alignment))]
let result = u32::from_le(ptr::read_unaligned(data_ptr as *const u32)) as usize;
self.data_ptr = data_ptr.offset(4);
result