Simplify prime guards and adopt unified mulmod

This commit is contained in:
Marek Lemańczyk committed 2025-10-13 16:56:50 +02:00
1 parent 3f5904c340
commit af909e9e2d
11 files changed
+236 -189

No files matched your search

+12 -1
View File
@@ -82,7 +82,8 @@ public sealed class DivisorCycleCache
ulong cached = snapshot[divisor];
if (cached == 0UL)
{
throw new InvalidDataException($"Divisor cycle is missing for {divisor}");
missingBuffer[missingCount++] = i;
continue;
}
cycles[i] = cached;
@@ -104,6 +105,16 @@ public sealed class DivisorCycleCache
{
ComputeCyclesCpu(divisors, cycles, missingIndices);
}
for (int j = 0; j < missingCount; j++)
{
int target = missingIndices[j];
ulong divisor = divisors[target];
if (divisor < (ulong)snapshot.Length)
{
snapshot[divisor] = cycles[target];
}
}
}
if (rentedMissing is not null)