Clear heuristic candidate list without try-finally

This commit is contained in:
Marek Lemańczyk committed 2025-10-15 23:57:46 +02:00
1 parent 51730bcba3
commit 0a23502441
1 file changed
+2 -6
+2 -6
View File
@@ -407,13 +407,12 @@ internal static partial class PrimeOrderCalculator
int capacity = config.MaxPowChecks <= 0 ? 64 : config.MaxPowChecks * 4; int capacity = config.MaxPowChecks <= 0 ? 64 : config.MaxPowChecks * 4;
List<ulong> candidates = AcquireHeuristicCandidateList(capacity); List<ulong> candidates = AcquireHeuristicCandidateList(capacity);
try
{
FactorEntry[] factorArray = orderFactors.Factors!; FactorEntry[] factorArray = orderFactors.Factors!;
// DebugLog("Building candidates list"); // DebugLog("Building candidates list");
BuildCandidates(order, factorArray, orderFactors.Count, candidates, capacity); BuildCandidates(order, factorArray, orderFactors.Count, candidates, capacity);
if (candidates.Count == 0) if (candidates.Count == 0)
{ {
candidates.Clear();
return false; return false;
} }
@@ -514,6 +513,7 @@ internal static partial class PrimeOrderCalculator
pool.Return(gpuPool, clearArray: false); pool.Return(gpuPool, clearArray: false);
} }
candidates.Clear();
result = candidate; result = candidate;
return true; return true;
} }
@@ -526,11 +526,7 @@ internal static partial class PrimeOrderCalculator
index += batchSize; index += batchSize;
} }
}
finally
{
candidates.Clear(); candidates.Clear();
}
// DebugLog("No candidate confirmed"); // DebugLog("No candidate confirmed");
return false; return false;
} }