IsPrime cache reused
This commit is contained in:
1 parent
10751bf841
commit
4c81f9e5a2
1 file changed
+6
-1
@@ -906,7 +906,12 @@ internal static partial class PrimeOrderCalculator
|
||||
for (int i = 0; i < pendingCount; i++)
|
||||
{
|
||||
ulong composite = pending[i];
|
||||
bool isPrime = Open.Numeric.Primes.Prime.Numbers.IsPrime(composite);
|
||||
if (!primalityCache!.TryGetValue(composite, out bool isPrime))
|
||||
{
|
||||
// Console.WriteLine($"Checking composite {composite}");
|
||||
isPrime = Open.Numeric.Primes.Prime.Numbers.IsPrime(composite);
|
||||
_ = primalityCache.TryAdd(composite, isPrime);
|
||||
}
|
||||
if (isPrime)
|
||||
{
|
||||
AddFactorToCollector(ref useDictionary, ref counts, primeSlots, exponentSlots, ref factorCount, composite, 1);
|
||||
|
||||
Reference in new issue
Block a user