diff --git a/PKHeX.Core/Legality/Tables/Tables.cs b/PKHeX.Core/Legality/Tables/Tables.cs index c2b531587..f6b4ae3e5 100644 --- a/PKHeX.Core/Legality/Tables/Tables.cs +++ b/PKHeX.Core/Legality/Tables/Tables.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using static PKHeX.Core.Species; @@ -90,7 +91,7 @@ public static partial class Legal (int)Meowstic, // (M/F) form specific }; - private static bool[] GetPermitList(int max, IEnumerable held) + private static bool[] GetPermitList(int max, ReadOnlySpan held) { var result = new bool[max + 1]; foreach (var item in held) @@ -98,7 +99,7 @@ private static bool[] GetPermitList(int max, IEnumerable held) return result; } - private static bool[] GetPermitList(int max, IEnumerable held, IEnumerable unreleased) + private static bool[] GetPermitList(int max, ReadOnlySpan held, ReadOnlySpan unreleased) { var result = GetPermitList(max, held); foreach (var u in unreleased) diff --git a/PKHeX.Core/Legality/Tables/Tables3.cs b/PKHeX.Core/Legality/Tables/Tables3.cs index 7034f4b1d..489c62e1d 100644 --- a/PKHeX.Core/Legality/Tables/Tables3.cs +++ b/PKHeX.Core/Legality/Tables/Tables3.cs @@ -82,7 +82,7 @@ public static partial class Legal 590, 591, 592, 593, }; - internal static readonly bool[] ReleasedHeldItems_3 = GetPermitList(MaxItemID_3, HeldItems_RS, new ushort[] {005}); // Safari Ball + internal static readonly bool[] ReleasedHeldItems_3 = GetPermitList(MaxItemID_3, HeldItems_RS, stackalloc ushort[] {005}); // Safari Ball // 064 is an unused location for Meteor Falls // 084 is Inside of a truck, no possible pokemon can be hatched there diff --git a/PKHeX.Core/Legality/Tables/Tables4.cs b/PKHeX.Core/Legality/Tables/Tables4.cs index 788470908..f70065b9a 100644 --- a/PKHeX.Core/Legality/Tables/Tables4.cs +++ b/PKHeX.Core/Legality/Tables/Tables4.cs @@ -90,7 +90,7 @@ public static partial class Legal internal static readonly ushort[] HeldItems_HGSS = ArrayUtil.ConcatAll(Pouch_Items_HGSS, Pouch_Mail_HGSS, Pouch_Medicine_HGSS, Pouch_Berries_HGSS, Pouch_Ball_Pt, Pouch_TMHM_HGSS.Slice(0, Pouch_TMHM_HGSS.Length - 8)); #endregion - internal static readonly bool[] ReleasedHeldItems_4 = GetPermitList(MaxItemID_4_HGSS, HeldItems_HGSS, new ushort[] + internal static readonly bool[] ReleasedHeldItems_4 = GetPermitList(MaxItemID_4_HGSS, HeldItems_HGSS, stackalloc ushort[] { 005, // Safari Ball 016, // Cherish Ball diff --git a/PKHeX.Core/Legality/Tables/Tables5.cs b/PKHeX.Core/Legality/Tables/Tables5.cs index 11352b330..eb690f6b2 100644 --- a/PKHeX.Core/Legality/Tables/Tables5.cs +++ b/PKHeX.Core/Legality/Tables/Tables5.cs @@ -38,7 +38,7 @@ public static partial class Legal 437, 442, 447, 450, 453, 458, 465, 466, 471, 504, 578, 616, 617, 621, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, }; - internal static readonly bool[] ReleasedHeldItems_5 = GetPermitList(MaxItemID_5_B2W2, HeldItems_BW, new ushort[] + internal static readonly bool[] ReleasedHeldItems_5 = GetPermitList(MaxItemID_5_B2W2, HeldItems_BW, stackalloc ushort[] { 005, // Safari Ball 016, // Cherish Ball diff --git a/PKHeX.Core/Legality/Tables/Tables6.cs b/PKHeX.Core/Legality/Tables/Tables6.cs index 7eb438717..4e7e836ab 100644 --- a/PKHeX.Core/Legality/Tables/Tables6.cs +++ b/PKHeX.Core/Legality/Tables/Tables6.cs @@ -168,7 +168,7 @@ public static partial class Legal 332, 334, 336, 338, 340, 342, 344, 346, 350, 352, 354, }; - internal static readonly bool[] ReleasedHeldItems_6 = GetPermitList(MaxItemID_6_AO, HeldItem_AO, new ushort[] + internal static readonly bool[] ReleasedHeldItems_6 = GetPermitList(MaxItemID_6_AO, HeldItem_AO, stackalloc ushort[] { 005, // Safari Ball 016, // Cherish Ball diff --git a/PKHeX.Core/Legality/Tables/Tables7.cs b/PKHeX.Core/Legality/Tables/Tables7.cs index 2018512b8..01725458b 100644 --- a/PKHeX.Core/Legality/Tables/Tables7.cs +++ b/PKHeX.Core/Legality/Tables/Tables7.cs @@ -234,7 +234,7 @@ public static partial class Legal }; #region Unreleased Items - internal static readonly bool[] ReleasedHeldItems_7 = GetPermitList(MaxItemID_7_USUM, HeldItems_USUM, new ushort[] + internal static readonly bool[] ReleasedHeldItems_7 = GetPermitList(MaxItemID_7_USUM, HeldItems_USUM, stackalloc ushort[] { 005, // Safari Ball 016, // Cherish Ball diff --git a/PKHeX.Core/Legality/Tables/Tables8.cs b/PKHeX.Core/Legality/Tables/Tables8.cs index 16bb86a36..b8b7633ba 100644 --- a/PKHeX.Core/Legality/Tables/Tables8.cs +++ b/PKHeX.Core/Legality/Tables/Tables8.cs @@ -230,7 +230,7 @@ public static partial class Legal public static bool IsDynamaxCrystal(ushort item) => item is >= DMAX_START and <= DMAX_END; public static bool IsDynamaxCrystalAvailable(ushort item) => item is >= DMAX_START and <= DMAX_LEGAL_END; - internal static readonly bool[] ReleasedHeldItems_8 = GetPermitList(MaxItemID_8, HeldItems_SWSH, new ushort[] + internal static readonly bool[] ReleasedHeldItems_8 = GetPermitList(MaxItemID_8, HeldItems_SWSH, stackalloc ushort[] { 298, // Flame Plate 299, // Splash Plate diff --git a/PKHeX.Core/Legality/Tables/Tables8bs.cs b/PKHeX.Core/Legality/Tables/Tables8bs.cs index c4b1328d9..d7d4a82e7 100644 --- a/PKHeX.Core/Legality/Tables/Tables8bs.cs +++ b/PKHeX.Core/Legality/Tables/Tables8bs.cs @@ -95,7 +95,7 @@ public static partial class Legal internal static readonly ushort[] HeldItems_BS = ArrayUtil.ConcatAll(Pouch_Items_BS, Pouch_Berries_BS, Pouch_TMHM_BS, Pouch_Medicine_BS, Pouch_Treasure_BS); #region Unreleased Items - internal static readonly bool[] ReleasedHeldItems_8b = GetPermitList(MaxItemID_8b, HeldItems_BS, new ushort[] + internal static readonly bool[] ReleasedHeldItems_8b = GetPermitList(MaxItemID_8b, HeldItems_BS, stackalloc ushort[] { 044, // Sacred Ash 537, // Prism Scale