From 41a86e3470b7cc8b5cc17f9d20f86679b325715d Mon Sep 17 00:00:00 2001 From: Andrew Sun Date: Mon, 2 Sep 2024 22:33:41 -0400 Subject: [PATCH] rustfmt --- src/decode/mod.rs | 21 ++++++++++++++++----- src/encode/mod.rs | 5 ++++- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/decode/mod.rs b/src/decode/mod.rs index 75da50e..c0e897c 100644 --- a/src/decode/mod.rs +++ b/src/decode/mod.rs @@ -192,7 +192,10 @@ pub unsafe fn decode_unsafe(bytes: *const u8) -> (T, usize) { // let varint_part0 = b0 & !(0xffffffffffffffff << len0.min(63)); // let varint_part1 = b1 & !(0xffffffffffffffff << (((msbs0 == 0) as u32) * len1.min(63))); - let num = T::vector_to_num(core::mem::transmute::<[u64; 2], [u8; 16]>([varint_part0, varint_part1])); + let num = T::vector_to_num(core::mem::transmute::<[u64; 2], [u8; 16]>([ + varint_part0, + varint_part1, + ])); let len = if msbs0 == 0 { len1 + 64 } else { len0 } / 8; (num, len as usize) @@ -327,7 +330,9 @@ unsafe fn decode_two_u32_unsafe( second_num = U::cast_u32(x[2]); } else { first_num = T::vector_to_num(core::mem::transmute::<__m128i, [u8; 16]>(comb)); - second_num = U::vector_to_num(core::mem::transmute::<__m128i, [u8; 16]>(_mm_bsrli_si128(comb, 8))); + second_num = U::vector_to_num(core::mem::transmute::<__m128i, [u8; 16]>(_mm_bsrli_si128( + comb, 8, + ))); } (first_num, second_num, first_len, second_len) @@ -744,9 +749,15 @@ unsafe fn decode_four_u16_unsafe< fourth_num = W::cast_u32(x[3]); } else { first_num = T::vector_to_num(core::mem::transmute::<__m128i, [u8; 16]>(comb)); - second_num = U::vector_to_num(core::mem::transmute::<__m128i, [u8; 16]>(_mm_bsrli_si128(comb, 4))); - third_num = V::vector_to_num(core::mem::transmute::<__m128i, [u8; 16]>(_mm_bsrli_si128(comb, 8))); - fourth_num = W::vector_to_num(core::mem::transmute::<__m128i, [u8; 16]>(_mm_bsrli_si128(comb, 12))); + second_num = U::vector_to_num(core::mem::transmute::<__m128i, [u8; 16]>(_mm_bsrli_si128( + comb, 4, + ))); + third_num = V::vector_to_num(core::mem::transmute::<__m128i, [u8; 16]>(_mm_bsrli_si128( + comb, 8, + ))); + fourth_num = W::vector_to_num(core::mem::transmute::<__m128i, [u8; 16]>(_mm_bsrli_si128( + comb, 12, + ))); } ( diff --git a/src/encode/mod.rs b/src/encode/mod.rs index 68be48d..ceae1ce 100644 --- a/src/encode/mod.rs +++ b/src/encode/mod.rs @@ -86,7 +86,10 @@ pub unsafe fn encode_unsafe(num: T) -> ([u8; 16], u8) { let merged = stage1 | (msbs & msbmask); - (core::mem::transmute::<[u64; 2], [u8; 16]>([merged, 0]), bytes_needed as u8) + ( + core::mem::transmute::<[u64; 2], [u8; 16]>([merged, 0]), + bytes_needed as u8, + ) } else { // Break the number into 7-bit parts and spread them out into a vector let stage1: __m128i = core::mem::transmute(num.num_to_vector_stage1());