Add TODOs for divisor metadata caching

This commit is contained in:
Marek Lemańczyk committed 2025-10-01 22:52:21 +02:00
1 parent 513fc7acb0
commit 36d316d19c
53 files changed
+929 -393

No files matched your search

@@ -36,6 +36,8 @@ internal struct CycleRemainderStepper
ulong remainder = prime;
if (remainder >= cycleLength)
{
// TODO: Swap this `%` for the shared divisor-cycle remainder helper so initialization reuses the cached
// cycle deltas benchmarked faster than on-the-fly modulo work.
remainder %= cycleLength;
}
_previousPrime = prime;
@@ -63,6 +65,8 @@ internal struct CycleRemainderStepper
if (ulong.MaxValue - _currentRemainder < delta)
{
UInt128 extended = (UInt128)_currentRemainder + delta;
// TODO: Replace this `%` with the UInt128-aware cycle reducer so large deltas use the cached subtraction
// ladder instead of falling back to the slower modulo implementation.
_currentRemainder = (ulong)(extended % cycleLength);
return _currentRemainder;
}
@@ -74,6 +78,8 @@ internal struct CycleRemainderStepper
_currentRemainder -= cycleLength;
if (_currentRemainder >= cycleLength)
{
// TODO: Route this `%` through the shared divisor-cycle helper so repeated wrap-arounds avoid
// modulo operations and match the benchmarked fast path.
_currentRemainder %= cycleLength;
}
}