From 54d6fba6c5686c00189b0bc13f137f38c343d395 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 13 Sep 2022 12:45:42 -0400 Subject: [PATCH] cleanup --- utils/src/memory.rs | 98 +-------------------------------------------- 1 file changed, 2 insertions(+), 96 deletions(-) diff --git a/utils/src/memory.rs b/utils/src/memory.rs index 035f3c4fe..9686a647b 100644 --- a/utils/src/memory.rs +++ b/utils/src/memory.rs @@ -23,24 +23,6 @@ mod fast_int_memory_access { unsafe { *b.as_ptr().cast() } } - #[inline(always)] - pub fn i64_from_le_bytes(b: &[u8]) -> i64 { - assert!(b.len() >= 8); - unsafe { *b.as_ptr().cast() } - } - - #[inline(always)] - pub fn i32_from_le_bytes(b: &[u8]) -> i32 { - assert!(b.len() >= 4); - unsafe { *b.as_ptr().cast() } - } - - #[inline(always)] - pub fn i16_from_le_bytes(b: &[u8]) -> i16 { - assert!(b.len() >= 2); - unsafe { *b.as_ptr().cast() } - } - #[inline(always)] pub fn u128_from_ne_bytes(b: &[u8]) -> u128 { assert!(b.len() >= 16); @@ -65,24 +47,6 @@ mod fast_int_memory_access { unsafe { *b.as_ptr().cast() } } - #[inline(always)] - pub fn i64_from_ne_bytes(b: &[u8]) -> i64 { - assert!(b.len() >= 8); - unsafe { *b.as_ptr().cast() } - } - - #[inline(always)] - pub fn i32_from_ne_bytes(b: &[u8]) -> i32 { - assert!(b.len() >= 4); - unsafe { *b.as_ptr().cast() } - } - - #[inline(always)] - pub fn i16_from_ne_bytes(b: &[u8]) -> i16 { - assert!(b.len() >= 2); - unsafe { *b.as_ptr().cast() } - } - #[inline(always)] pub fn u64_from_be_bytes(b: &[u8]) -> u64 { assert!(b.len() >= 8); @@ -100,24 +64,6 @@ mod fast_int_memory_access { assert!(b.len() >= 2); unsafe { *b.as_ptr().cast::() }.swap_bytes() } - - #[inline(always)] - pub fn i64_from_be_bytes(b: &[u8]) -> i64 { - assert!(b.len() >= 8); - unsafe { *b.as_ptr().cast::() }.swap_bytes() - } - - #[inline(always)] - pub fn i32_from_be_bytes(b: &[u8]) -> i32 { - assert!(b.len() >= 4); - unsafe { *b.as_ptr().cast::() }.swap_bytes() - } - - #[inline(always)] - pub fn i16_from_be_bytes(b: &[u8]) -> i16 { - assert!(b.len() >= 2); - unsafe { *b.as_ptr().cast::() }.swap_bytes() - } } #[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))] @@ -139,18 +85,8 @@ mod fast_int_memory_access { } #[inline(always)] - pub fn i64_from_le_bytes(b: &[u8]) -> i64 { - i64::from_le_bytes(b[..8].try_into().unwrap()) - } - - #[inline(always)] - pub fn i32_from_le_bytes(b: &[u8]) -> i32 { - i32::from_le_bytes(b[..4].try_into().unwrap()) - } - - #[inline(always)] - pub fn i16_from_le_bytes(b: &[u8]) -> i16 { - i16::from_le_bytes(b[..2].try_into().unwrap()) + pub fn u128_from_ne_bytes(b: &[u8]) -> u64 { + u128::from_ne_bytes(b[..16].try_into().unwrap()) } #[inline(always)] @@ -168,21 +104,6 @@ mod fast_int_memory_access { u16::from_ne_bytes(b[..2].try_into().unwrap()) } - #[inline(always)] - pub fn i64_from_ne_bytes(b: &[u8]) -> i64 { - i64::from_ne_bytes(b[..8].try_into().unwrap()) - } - - #[inline(always)] - pub fn i32_from_ne_bytes(b: &[u8]) -> i32 { - i32::from_ne_bytes(b[..4].try_into().unwrap()) - } - - #[inline(always)] - pub fn i16_from_ne_bytes(b: &[u8]) -> i16 { - i16::from_ne_bytes(b[..2].try_into().unwrap()) - } - #[inline(always)] pub fn u64_from_be_bytes(b: &[u8]) -> u64 { u64::from_be_bytes(b[..8].try_into().unwrap()) @@ -197,21 +118,6 @@ mod fast_int_memory_access { pub fn u16_from_be_bytes(b: &[u8]) -> u16 { u16::from_be_bytes(b[..2].try_into().unwrap()) } - - #[inline(always)] - pub fn i64_from_be_bytes(b: &[u8]) -> i64 { - i64::from_be_bytes(b[..8].try_into().unwrap()) - } - - #[inline(always)] - pub fn i32_from_be_bytes(b: &[u8]) -> i32 { - i32::from_be_bytes(b[..4].try_into().unwrap()) - } - - #[inline(always)] - pub fn i16_from_be_bytes(b: &[u8]) -> i16 { - i16::from_be_bytes(b[..2].try_into().unwrap()) - } } pub use fast_int_memory_access::*;