Compilation errors fixed.

This commit is contained in:
mlemanczyk committed 2025-10-12 00:37:57 +02:00
1 parent 4f73d89716
commit dde01cf8b9
2 files changed
+7 -14

No files matched your search

+5 -8
View File
@@ -1,6 +1,7 @@
using System.Buffers; using System.Buffers;
using System.Buffers.Binary; using System.Buffers.Binary;
using System.Diagnostics; using System.Diagnostics;
using System.Numerics;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using PerfectNumbers.Core.Gpu; using PerfectNumbers.Core.Gpu;
@@ -331,23 +332,19 @@ internal static partial class PrimeOrderCalculator
ArrayPool<FactorEntry> factorPool = FactorPool; ArrayPool<FactorEntry> factorPool = FactorPool;
FactorEntry[]? tempArray = null; FactorEntry[]? tempArray = null;
try
{
ReadOnlySpan<FactorEntry> factorSpan = factors.Factors; ReadOnlySpan<FactorEntry> factorSpan = factors.Factors;
int length = factors.Count; int length = factors.Count;
int capacity = length + 1; int capacity = length + 1;
Span<FactorEntry> buffer; Span<FactorEntry> buffer = capacity <= FactorEntryStackThreshold ? stackalloc FactorEntry[capacity] : default;
if (capacity <= FactorEntryStackThreshold) if (capacity > FactorEntryStackThreshold)
{
buffer = stackalloc FactorEntry[capacity];
}
else
{ {
tempArray = factorPool.Rent(capacity); tempArray = factorPool.Rent(capacity);
buffer = tempArray.AsSpan(0, capacity); buffer = tempArray.AsSpan(0, capacity);
} }
try
{
factorSpan.CopyTo(buffer); factorSpan.CopyTo(buffer);
bool isPrime = Open.Numeric.Primes.Prime.Numbers.IsPrime(factors.Cofactor); bool isPrime = Open.Numeric.Primes.Prime.Numbers.IsPrime(factors.Cofactor);
+2 -6
View File
@@ -347,14 +347,10 @@ public static class ULongExtensions
ulong result = divisor.MontgomeryOne; ulong result = divisor.MontgomeryOne;
ulong nPrime = divisor.NPrime; ulong nPrime = divisor.NPrime;
Span<ulong> oddPowerStorage; Span<ulong> oddPowerStorage = oddPowerCount <= PerfectNumberConstants.MaxOddPowersCount ? stackalloc ulong[PerfectNumberConstants.MaxOddPowersCount] : default;
ulong[]? pooledOddPowers = null; ulong[]? pooledOddPowers = null;
if (oddPowerCount <= PerfectNumberConstants.MaxOddPowersCount) if (oddPowerCount < PerfectNumberConstants.PooledArrayThreshold)
{
oddPowerStorage = stackalloc ulong[PerfectNumberConstants.MaxOddPowersCount];
}
else if (oddPowerCount < PerfectNumberConstants.PooledArrayThreshold)
{ {
oddPowerStorage = new ulong[oddPowerCount]; oddPowerStorage = new ulong[oddPowerCount];
} }