Simplify exception guards in CPU remainder paths

This commit is contained in:
Marek Lemańczyk committed 2025-10-21 20:52:14 +02:00
1 parent 6adf78faf6
commit 7baf3b619f
2 files changed
+2 -49

No files matched your search

+1 -17
View File
@@ -501,18 +501,6 @@ public class MersenneDivisorCycles
if (multiplicity > HeapMultiplicityCapacity)
{
if (heapCandidateArray is not null)
{
ThreadStaticPools.UlongPool.Return(heapCandidateArray);
}
if (heapEvaluationArray is not null)
{
ThreadStaticPools.BoolPool.Return(heapEvaluationArray);
}
ThreadStaticPools.ReturnExponentStepper(stepper);
ThreadStaticPools.UlongPool.Return(primes);
throw new InvalidOperationException($"Factor multiplicity {multiplicity} exceeds the supported limit of {HeapMultiplicityCapacity}.");
}
@@ -528,11 +516,7 @@ public class MersenneDivisorCycles
if (heapCandidateArray is not null)
{
ThreadStaticPools.UlongPool.Return(heapCandidateArray);
}
if (heapEvaluationArray is not null)
{
ThreadStaticPools.BoolPool.Return(heapEvaluationArray);
ThreadStaticPools.BoolPool.Return(heapEvaluationArray!);
}
return order;
@@ -235,19 +235,6 @@ internal static partial class PrimeOrderCalculator
if (exponent > ExponentHardLimit)
{
ThreadStaticPools.ReturnExponentStepper(stepper);
if (heapCandidateArray is not null)
{
ThreadStaticPools.UlongPool.Return(heapCandidateArray);
}
if (heapEvaluationArray is not null)
{
ThreadStaticPools.BoolPool.Return(heapEvaluationArray);
}
pool.Return(tempArray, clearArray: false);
throw new InvalidOperationException($"Prime factor exponent {exponent} exceeds the supported limit of {ExponentHardLimit}.");
}
@@ -267,11 +254,7 @@ internal static partial class PrimeOrderCalculator
if (heapCandidateArray is not null)
{
ThreadStaticPools.UlongPool.Return(heapCandidateArray);
}
if (heapEvaluationArray is not null)
{
ThreadStaticPools.BoolPool.Return(heapEvaluationArray);
ThreadStaticPools.BoolPool.Return(heapEvaluationArray!);
}
pool.Return(tempArray, clearArray: false);
@@ -412,13 +395,6 @@ internal static partial class PrimeOrderCalculator
if (exponent > ExponentHardLimit)
{
ThreadStaticPools.ReturnExponentStepper(stepper);
if (heapCandidateArray is not null)
{
ThreadStaticPools.UlongPool.Return(heapCandidateArray);
}
throw new InvalidOperationException($"Factor exponent {exponent} exceeds the supported limit of {ExponentHardLimit}.");
}
@@ -888,13 +864,6 @@ internal static partial class PrimeOrderCalculator
if (exponent > ExponentHardLimit)
{
ThreadStaticPools.ReturnExponentStepper(stepper);
if (heapCandidateArray is not null)
{
ThreadStaticPools.UlongPool.Return(heapCandidateArray);
}
throw new InvalidOperationException($"Candidate factor exponent {exponent} exceeds the supported limit of {ExponentHardLimit}.");
}