diff --git a/PerfectNumbers.Core/MersenneDivisorCycles.cs b/PerfectNumbers.Core/MersenneDivisorCycles.cs index e660c2a..942af1a 100644 --- a/PerfectNumbers.Core/MersenneDivisorCycles.cs +++ b/PerfectNumbers.Core/MersenneDivisorCycles.cs @@ -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; diff --git a/PerfectNumbers.Core/PrimeOrderCalculator.Cpu.cs b/PerfectNumbers.Core/PrimeOrderCalculator.Cpu.cs index 296279f..8bf676b 100644 --- a/PerfectNumbers.Core/PrimeOrderCalculator.Cpu.cs +++ b/PerfectNumbers.Core/PrimeOrderCalculator.Cpu.cs @@ -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}."); }