From b04ccea00829ec03b02182464d31435574363d1d Mon Sep 17 00:00:00 2001 From: Solomon Ucko Date: Wed, 10 Aug 2022 21:04:02 -0400 Subject: [PATCH] parameterize references to u128 --- src/logic.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/logic.rs b/src/logic.rs index 000bc3f..49dcd08 100644 --- a/src/logic.rs +++ b/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 } } }