Small optimizations

This commit is contained in:
Marek Lemańczyk committed 2025-10-04 03:07:17 +02:00
1 parent df71823c8f
commit 40dff45a81
1 file changed
+14 -42
+14 -42
View File
@@ -876,54 +876,26 @@ internal static partial class PrimeOrderCalculator
return order; return order;
} }
private readonly struct CandidateKey private readonly struct CandidateKey(int primary, long secondary, long tertiary)
{ {
public CandidateKey(int primary, long secondary, long tertiary) public readonly int Primary = primary;
{ public readonly long Secondary = secondary;
Primary = primary; public readonly long Tertiary = tertiary;
Secondary = secondary;
Tertiary = tertiary;
} }
public int Primary { get; } private readonly struct FactorEntry(ulong value, int exponent)
{
public long Secondary { get; } public readonly ulong Value = value;
public readonly int Exponent = exponent;
public long Tertiary { get; }
} }
private readonly struct FactorEntry private readonly struct PartialFactorResult(FactorEntry[]? factors, ulong cofactor, bool fullyFactored, int count)
{ {
public FactorEntry(ulong value, int exponent) public readonly FactorEntry[]? Factors = factors;
{ public readonly ulong Cofactor = cofactor;
Value = value; public readonly bool FullyFactored = fullyFactored;
Exponent = exponent; public readonly int Count = count;
} public readonly static PartialFactorResult Empty = new(null, 1UL, true, 0);
public ulong Value { get; }
public int Exponent { get; }
}
private readonly struct PartialFactorResult
{
public PartialFactorResult(FactorEntry[]? factors, ulong cofactor, bool fullyFactored, int count)
{
Factors = factors;
Cofactor = cofactor;
FullyFactored = fullyFactored;
Count = count;
}
public FactorEntry[]? Factors { get; }
public ulong Cofactor { get; }
public bool FullyFactored { get; }
public int Count { get; }
public static PartialFactorResult Empty => new(null, 1UL, true, 0);
public PartialFactorResult WithAdditionalPrime(ulong prime) public PartialFactorResult WithAdditionalPrime(ulong prime)
{ {