Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
as-com committed Sep 3, 2024
1 parent b8053f6 commit 41a86e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
21 changes: 16 additions & 5 deletions src/decode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,10 @@ pub unsafe fn decode_unsafe<T: VarIntTarget>(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)
Expand Down Expand Up @@ -327,7 +330,9 @@ unsafe fn decode_two_u32_unsafe<T: VarIntTarget, U: VarIntTarget>(
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)
Expand Down Expand Up @@ -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,
)));
}

(
Expand Down
5 changes: 4 additions & 1 deletion src/encode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ pub unsafe fn encode_unsafe<T: VarIntTarget>(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());
Expand Down

0 comments on commit 41a86e3

Please sign in to comment.