Trim unreachable MulMod conditionals
This commit is contained in:
1 parent
94323c2e8c
commit
c892e1c30c
2 files changed
+27
-14
No files matched your search
@@ -464,17 +464,20 @@ public static partial class ULongExtensions
|
||||
// return 0UL;
|
||||
// }
|
||||
|
||||
// The Pollard Rho walks keep both operands below the modulus, so skip re-folding them here.
|
||||
UInt128 sum = (UInt128)value + addend;
|
||||
UInt128 mod = modulus;
|
||||
if (sum >= mod)
|
||||
if (sum < modulus)
|
||||
{
|
||||
sum -= mod;
|
||||
if (sum >= mod)
|
||||
{
|
||||
sum -= mod;
|
||||
}
|
||||
return (ulong)sum;
|
||||
}
|
||||
|
||||
sum -= modulus;
|
||||
// After one subtraction the sum always falls below the modulus on this path, making the old guard redundant.
|
||||
// if (sum >= modulus)
|
||||
// {
|
||||
// sum -= modulus;
|
||||
// }
|
||||
|
||||
return (ulong)sum;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user