stackalloc temp unreleased item arrays

This commit is contained in:
Kurt
2022-08-29 16:08:30 -07:00
parent d8fe34011d
commit 40649084b3
8 changed files with 10 additions and 9 deletions

View File

@@ -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<ushort> held)
private static bool[] GetPermitList(int max, ReadOnlySpan<ushort> held)
{
var result = new bool[max + 1];
foreach (var item in held)
@@ -98,7 +99,7 @@ private static bool[] GetPermitList(int max, IEnumerable<ushort> held)
return result;
}
private static bool[] GetPermitList(int max, IEnumerable<ushort> held, IEnumerable<ushort> unreleased)
private static bool[] GetPermitList(int max, ReadOnlySpan<ushort> held, ReadOnlySpan<ushort> unreleased)
{
var result = GetPermitList(max, held);
foreach (var u in unreleased)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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