From 59bc35a46594546f401ebceb12359b048008de40 Mon Sep 17 00:00:00 2001 From: Kazuyuki Tanimura Date: Mon, 22 Apr 2024 14:10:43 -0700 Subject: [PATCH] chore: Remove unused functions --- core/src/common/bit.rs | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/core/src/common/bit.rs b/core/src/common/bit.rs index f73634738..2cd1871dd 100644 --- a/core/src/common/bit.rs +++ b/core/src/common/bit.rs @@ -142,18 +142,6 @@ macro_rules! read_num_be_bytes { }}; } -/// Converts value `val` of type `T` to a byte vector, by reading `num_bytes` from `val`. -/// NOTE: if `val` is less than the size of `T` then it can be truncated. -#[inline] -pub fn convert_to_bytes(val: &T, num_bytes: usize) -> Vec -where - T: ?Sized + AsBytes, -{ - let mut bytes: Vec = vec![0; num_bytes]; - memcpy_value(val.as_bytes(), num_bytes, &mut bytes); - bytes -} - #[inline] pub fn memcpy(source: &[u8], target: &mut [u8]) { debug_assert!(target.len() >= source.len(), "Copying from source to target is not possible. Source has {} bytes but target has {} bytes", source.len(), target.len()); @@ -203,10 +191,6 @@ pub fn trailing_bits(v: u64, num_bits: usize) -> u64 { (v << n) >> n } -pub fn set_bit_value(bits: &mut [u8], i: usize, val: bool) { - bits[i / 8] |= (val as u8) << (i % 8); -} - #[inline] pub fn set_bit(bits: &mut [u8], i: usize) { bits[i / 8] |= 1 << (i % 8); @@ -257,17 +241,6 @@ pub fn set_bits(bits: &mut [u8], offset: usize, length: usize) { } } -/// Returns the minimum number of bits needed to represent the value 'x' -#[inline] -pub fn num_required_bits(x: u64) -> usize { - for i in (0..64).rev() { - if x & (1u64 << i) != 0 { - return i + 1; - } - } - 0 -} - #[inline(always)] pub fn mix_hash(lower: u64, upper: u64) -> u64 { let hash = (17 * 37u64).wrapping_add(lower); @@ -1170,18 +1143,6 @@ mod tests { } } - #[test] - fn test_num_required_bits() { - assert_eq!(num_required_bits(0), 0); - assert_eq!(num_required_bits(1), 1); - assert_eq!(num_required_bits(2), 2); - assert_eq!(num_required_bits(4), 3); - assert_eq!(num_required_bits(8), 4); - assert_eq!(num_required_bits(10), 4); - assert_eq!(num_required_bits(12), 4); - assert_eq!(num_required_bits(16), 5); - } - #[test] fn test_get_bit() { // 00001101