PKHeX/PKHeX.Core/Legality/Structures/CheckResult.cs
Kurt 69fafcab83 Performance: Slightly reduce allocations in moveset validation (#3460)
* Reuses move parse result objects for each encounter parsed in a LegalityCheck attempt, instead of creating a new object.
* Ensures the objects are never-null, and makes cleanup easier.

Slightly adjusts some other parts of the moveset validation to reduce allocations.
2022-03-12 17:39:00 -08:00

16 lines
669 B
C#

namespace PKHeX.Core;
/// <summary>
/// Result of a Legality Check
/// </summary>
public sealed record CheckResult(Severity Judgement, string Comment, CheckIdentifier Identifier) : ICheckResult
{
public bool Valid => Judgement >= Severity.Fishy;
public string Rating => Judgement.Description();
internal CheckResult(CheckIdentifier i) : this(Severity.Valid, LegalityCheckStrings.L_AValid, i) { }
public override string ToString() => $"{Identifier}: {Comment}";
public string Format(string format) => string.Format(format, Rating, Comment);
public string Format(string format, int index) => string.Format(format, Rating, index, Comment);
}