mirror of
https://gitlab.com/artofrev/smallint.git
synced 2024-12-04 09:01:39 -05:00
use function names instead of punctuation
This commit is contained in:
parent
ab76eb30f5
commit
8cf2d6b870
20
src/logic.rs
20
src/logic.rs
|
@ -91,24 +91,24 @@ macro_rules! logic_op {
|
|||
|
||||
|
||||
macro_rules! inline_heap_to_inline {
|
||||
($op:tt; $i:ident, $slice:ident) => {
|
||||
($fun:tt; $i:ident, $slice:ident) => {
|
||||
let mut j = 0u128;
|
||||
for i in 0..4 {
|
||||
j <<= 32;
|
||||
j |= $slice[3 - i] as u128;
|
||||
}
|
||||
SmallUint(SmallUintType::Inline($i $op j))
|
||||
SmallUint(SmallUintType::Inline($i.$fun(j)))
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! inline_heap_to_heap {
|
||||
($op_assign:tt; $i:ident, $slice:ident) => {
|
||||
($fun_assign:ident; $i:ident, $slice:ident) => {
|
||||
let mut retvec = $slice.to_vec();
|
||||
|
||||
let mut v = $i;
|
||||
#[allow(clippy::needless_range_loop)]
|
||||
for r in 0..4 {
|
||||
retvec[r] $op_assign v as u32;
|
||||
retvec[r].$fun_assign(v as u32);
|
||||
|
||||
v >>= 32;
|
||||
}
|
||||
|
@ -121,10 +121,10 @@ macro_rules! inline_heap_to_heap {
|
|||
|
||||
|
||||
macro_rules! heap_heap_create_res_shortest {
|
||||
($op:tt; $min:ident, $slice1:ident, $slice2:ident) => {
|
||||
($fun:ident; $min:ident, $slice1:ident, $slice2:ident) => {
|
||||
let mut res = Vec::with_capacity($min);
|
||||
for l in 0..$min {
|
||||
res.push($slice1[l] $op $slice2[l]);
|
||||
res.push($slice1[l].$fun($slice2[l]));
|
||||
}
|
||||
res
|
||||
}
|
||||
|
@ -175,15 +175,15 @@ macro_rules! heap_heap_return_any {
|
|||
logic_op! {
|
||||
BitAnd, BitAndAssign, SmallUint, SmallUintType, bitand, bitand_assign;
|
||||
i, j, r, s, slice, slice1, slice2, min, res;
|
||||
{ inline_heap_to_inline! { &; i, slice } },
|
||||
{ heap_heap_create_res_shortest! { &; min, slice1, slice2 } },
|
||||
{ inline_heap_to_inline! { bitand; i, slice } },
|
||||
{ heap_heap_create_res_shortest! { bitand; min, slice1, slice2 } },
|
||||
{ heap_heap_return_any! { res } }
|
||||
}
|
||||
|
||||
logic_op! {
|
||||
BitOr, BitOrAssign, SmallUint, SmallUintType, bitor, bitor_assign;
|
||||
i, j, r, s, slice, slice1, slice2, min, res;
|
||||
{ inline_heap_to_heap! { |=; i, slice } },
|
||||
{ inline_heap_to_heap! { bitor_assign; i, slice } },
|
||||
{ heap_heap_create_res_longest! { bitor; slice1, slice2, min }},
|
||||
{ heap_heap_return_heap! { res } }
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ logic_op! {
|
|||
logic_op! {
|
||||
BitXor, BitXorAssign, SmallUint, SmallUintType, bitxor, bitxor_assign;
|
||||
i, j, r, s, slice, slice1, slice2, min, res;
|
||||
{ inline_heap_to_heap! { ^=; i, slice } },
|
||||
{ inline_heap_to_heap! { bitxor_assign; i, slice } },
|
||||
{ heap_heap_create_res_longest! { bitxor; slice1, slice2, min }},
|
||||
{ heap_heap_return_any! { res } }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user