Reduce npclock object size

24 bytes per object -> 16 bytes
2,624 objects are made for legality checking; reduces from 73KB to 41KB
removing unnecessary clone recreation -> count from 2624 -> 414 (41KB to
6.6KB)
yay 10x reduction; not huge in the big picture but a fun exercise
This commit is contained in:
Kurt 2019-01-06 20:58:57 -08:00
parent 2a8b43d9c7
commit 950ddcf9fd
3 changed files with 22 additions and 25 deletions

View file

@ -68,7 +68,7 @@
Species = 212, // Scizor
Locks = new[] {
new NPCLock(198, 13, 1, 191), // Murkrow (F) (Jolly)
new NPCLock(344, 02, 2, 256), // Claydol (-) (Brave)
new NPCLock(344, 02, 2, 255), // Claydol (-) (Brave)
new NPCLock(208, 03, 0, 127), // Steelix (M) (Adamant)
new NPCLock(212, 11, 0, 127), // Scizor (M) (Hasty) -- itself!
}};
@ -111,7 +111,7 @@
Locks = new[] {
new NPCLock(116, 24, 0, 063), // Horsea (M) (Quirky)
new NPCLock(118, 12, 1, 127), // Goldeen (F) (Serious)
new NPCLock(374, 00, 2, 256), // Beldum (-) (Hardy)
new NPCLock(374, 00, 2, 255), // Beldum (-) (Hardy)
}};
public static readonly TeamLock XGulpin = new TeamLock {
@ -165,7 +165,7 @@
Species = 322, // Numel
Locks = new[] {
new NPCLock(280, 06, 0, 127), // Ralts (M) (Docile)
new NPCLock(100, 00, 2, 256), // Voltorb (-) (Hardy)
new NPCLock(100, 00, 2, 255), // Voltorb (-) (Hardy)
new NPCLock(371, 24, 1, 127), // Bagon (F) (Quirky)
}};
@ -371,7 +371,7 @@
public static readonly TeamLock XMagneton = new TeamLock {
Species = 082, // Magneton
Locks = new[] {
new NPCLock(292, 18, 2, 256), // Shedinja (-) (Bashful)
new NPCLock(292, 18, 2, 255), // Shedinja (-) (Bashful)
new NPCLock(202, 00, 0, 127), // Wobbuffet (M) (Hardy)
new NPCLock(329, 12, 1, 127), // Vibrava (F) (Serious)
}};
@ -522,17 +522,17 @@
public static readonly TeamLock XKangaskhan = new TeamLock {
Species = 115, // Kangaskhan
Locks = new[] {
new NPCLock(101, 00, 2, 256), // Electrode (-) (Hardy)
new NPCLock(101, 00, 2, 255), // Electrode (-) (Hardy)
new NPCLock(200, 18, 1, 127), // Misdreavus (F) (Bashful)
new NPCLock(344, 12, 2, 256), // Claydol (-) (Serious)
new NPCLock(344, 12, 2, 255), // Claydol (-) (Serious)
}};
public static readonly TeamLock XBanette = new TeamLock {
Species = 354, // Banette
Locks = new[] {
new NPCLock(101, 00, 2, 256), // Electrode (-) (Hardy)
new NPCLock(101, 00, 2, 255), // Electrode (-) (Hardy)
new NPCLock(200, 18, 1, 127), // Misdreavus (F) (Bashful)
new NPCLock(344, 12, 2, 256), // Claydol (-) (Serious)
new NPCLock(344, 12, 2, 255), // Claydol (-) (Serious)
new NPCLock(115), // Shadow Kangaskhan
}};
@ -540,9 +540,9 @@
Species = 354, // Banette
Comment = "Kangaskhan Seen",
Locks = new[] {
new NPCLock(101, 00, 2, 256), // Electrode (-) (Hardy)
new NPCLock(101, 00, 2, 255), // Electrode (-) (Hardy)
new NPCLock(200, 18, 1, 127), // Misdreavus (F) (Bashful)
new NPCLock(344, 12, 2, 256), // Claydol (-) (Serious)
new NPCLock(344, 12, 2, 255), // Claydol (-) (Serious)
new NPCLock(115, true), // Shadow Kangaskhan (Seen)
}};
@ -613,7 +613,7 @@
Locks = new[] {
new NPCLock(326, 18, 0, 127), // Grumpig (M) (Bashful)
new NPCLock(227, 12, 1, 127), // Skarmory (F) (Serious)
new NPCLock(375, 06, 2, 256), // Metang (-) (Docile)
new NPCLock(375, 06, 2, 255), // Metang (-) (Docile)
new NPCLock(297, 24, 1, 063), // Hariyama (F) (Quirky)
}};
@ -621,7 +621,7 @@
Species = 108, // Lickitung
Locks = new[] {
new NPCLock(171, 24, 0, 127), // Lanturn (M) (Quirky)
new NPCLock(082, 06, 2, 256), // Magneton (-) (Docile)
new NPCLock(082, 06, 2, 255), // Magneton (-) (Docile)
}};
public static readonly TeamLock XScyther = new TeamLock {
@ -652,7 +652,7 @@
public static readonly TeamLock XSolrock = new TeamLock {
Species = 338, // Solrock
Locks = new[] {
new NPCLock(375, 24, 2, 256), // Metang (-) (Quirky)
new NPCLock(375, 24, 2, 255), // Metang (-) (Quirky)
new NPCLock(195, 06, 0, 127), // Quagsire (M) (Docile)
new NPCLock(212, 00, 1, 127), // Scizor (F) (Hardy)
}};
@ -660,7 +660,7 @@
public static readonly TeamLock XStarmie = new TeamLock {
Species = 121, // Starmie
Locks = new[] {
new NPCLock(375, 24, 2, 256), // Metang (-) (Quirky)
new NPCLock(375, 24, 2, 255), // Metang (-) (Quirky)
new NPCLock(195, 06, 0, 127), // Quagsire (M) (Docile)
new NPCLock(212, 00, 1, 127), // Scizor (F) (Hardy)
new NPCLock(338), // Shadow Solrock
@ -671,7 +671,7 @@
Species = 121, // Starmie
Comment = "Solrock Seen",
Locks = new[] {
new NPCLock(375, 24, 2, 256), // Metang (-) (Quirky)
new NPCLock(375, 24, 2, 255), // Metang (-) (Quirky)
new NPCLock(195, 06, 0, 127), // Quagsire (M) (Docile)
new NPCLock(212, 00, 1, 127), // Scizor (F) (Hardy)
new NPCLock(338, true), // Shadow Solrock (Seen)

View file

@ -5,14 +5,14 @@ namespace PKHeX.Core
/// </summary>
public sealed class NPCLock
{
public readonly int Species;
public readonly uint Nature;
public readonly uint Gender;
public readonly uint Ratio;
public readonly short Species;
public readonly byte Nature;
public readonly byte Gender;
public readonly byte Ratio;
public readonly bool Shadow;
public readonly bool Seen;
public NPCLock(int s, uint n, uint g, uint r)
public NPCLock(short s, byte n, byte g, byte r)
{
Species = s;
Nature = n;
@ -20,7 +20,7 @@ namespace PKHeX.Core
Ratio = r;
}
public NPCLock(int s, bool seen = false)
public NPCLock(short s, bool seen = false)
{
Species = s;
Nature = 25;

View file

@ -8,10 +8,7 @@ namespace PKHeX.Core
internal TeamLock Clone()
{
var c = new TeamLock { Comment = Comment, Locks = (NPCLock[])Locks.Clone() };
for (int i = 0; i < Locks.Length; i++)
Locks[i] = Locks[i].Clone();
return c;
return new TeamLock { Comment = Comment, Locks = (NPCLock[])Locks.Clone() };
}
}
}