mirror of
https://gitlab.com/artofrev/smallint.git
synced 2024-12-04 17:11:38 -05:00
parameterize references to u128
This commit is contained in:
parent
f890aab454
commit
b04ccea008
18
src/logic.rs
18
src/logic.rs
|
@ -97,11 +97,11 @@ macro_rules! logic_op {
|
|||
|
||||
|
||||
macro_rules! inline_heap_to_inline {
|
||||
($fun:ident, $typ:ident, $typ_inner:ident; $i:ident, $slice:ident) => {
|
||||
let mut j = 0u128;
|
||||
($fun:ident, $typ:ident, $typ_inner:ident, $typ_inline:ident; $i:ident, $slice:ident) => {
|
||||
let mut j = 0;
|
||||
for i in 0..4 {
|
||||
j <<= 32;
|
||||
j |= $slice[3 - i] as u128;
|
||||
j |= $slice[3 - i] as $typ_inline;
|
||||
}
|
||||
$typ($typ_inner::Inline($i.$fun(j)))
|
||||
}
|
||||
|
@ -159,16 +159,16 @@ macro_rules! heap_heap_return_heap {
|
|||
}
|
||||
|
||||
macro_rules! heap_heap_return_any {
|
||||
($typ:ident, $typ_inner:ident; $res:ident) => {
|
||||
($typ:ident, $typ_inner:ident, $typ_inline:ident; $res:ident) => {
|
||||
while $res.len() != 1 && $res[$res.len() - 1] == 0 {
|
||||
$res.pop();
|
||||
}
|
||||
|
||||
if $res.len() <= 4 {
|
||||
let mut r = 0u128;
|
||||
let mut r = 0;
|
||||
for t in 0..$res.len() {
|
||||
r <<= 32;
|
||||
r |= $res[$res.len() - 1 - t] as u128;
|
||||
r |= $res[$res.len() - 1 - t] as $typ_inline;
|
||||
}
|
||||
$typ($typ_inner::Inline(r))
|
||||
} else {
|
||||
|
@ -181,9 +181,9 @@ macro_rules! heap_heap_return_any {
|
|||
logic_op! {
|
||||
BitAnd, BitAndAssign, SmallUint, SmallUintType, bitand, bitand_assign;
|
||||
i, j, p, q, s, t, slice, slice1, slice2, min, res;
|
||||
{ inline_heap_to_inline! { bitand, SmallUint, SmallUintType; i, slice } },
|
||||
{ inline_heap_to_inline! { bitand, SmallUint, SmallUintType, u128; i, slice } },
|
||||
{ heap_heap_create_res_shortest! { bitand; min, slice1, slice2 } },
|
||||
{ heap_heap_return_any! { SmallUint, SmallUintType; res } }
|
||||
{ heap_heap_return_any! { SmallUint, SmallUintType, u128; res } }
|
||||
}
|
||||
|
||||
logic_op! {
|
||||
|
@ -199,7 +199,7 @@ logic_op! {
|
|||
i, j, p, q, s, t, slice, slice1, slice2, min, res;
|
||||
{ inline_heap_to_heap! { bitxor_assign, SmallUint, SmallUintType; i, slice } },
|
||||
{ heap_heap_create_res_longest! { bitxor; slice1, slice2, min }},
|
||||
{ heap_heap_return_any! { SmallUint, SmallUintType; res } }
|
||||
{ heap_heap_return_any! { SmallUint, SmallUintType, u128; res } }
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user