factor::numeric: Simplify inv_mod_u64

Just call `u64::wrapping_{mul,sub}` instead of (de)constructing Wrapping<u64>
values.
This commit is contained in:
nicoo 2020-05-31 13:12:30 +02:00
parent 918035e01e
commit 19a0645a0a

View file

@ -173,12 +173,12 @@ pub(crate) fn inv_mod_u64(a: u64) -> u64 {
r r
} / newr; } / newr;
let (tp, Wrapping(newtp)) = (newt, Wrapping(t) - (Wrapping(quot) * Wrapping(newt))); let newtp = t.wrapping_sub(quot.wrapping_mul(newt));
t = tp; t = newt;
newt = newtp; newt = newtp;
let (rp, Wrapping(newrp)) = (newr, Wrapping(r) - (Wrapping(quot) * Wrapping(newr))); let newrp = r.wrapping_sub(quot.wrapping_mul(newr));
r = rp; r = newr;
newr = newrp; newr = newrp;
} }