Pre-allocate some dictionary sizes

Skips the bucket array resizing steps
a 256 key dict will garbage 5KB; StringConverter2KOR wastes 100KB of garbage.

Zukan7b: save 144 bytes and eliminate cctor
This commit is contained in:
Kurt 2023-03-04 20:00:27 -08:00
parent 2c405f98b1
commit 29b3b695bd
6 changed files with 92 additions and 84 deletions

View file

@ -211,7 +211,7 @@ internal static class Encounters8Nest
/// <summary>
/// Location IDs containing Dens that cannot be accessed without Rotom Bike's Water Mode.
/// </summary>
internal static readonly HashSet<byte> InaccessibleRank12DistributionLocations = new() {154,178,186,188,190,192,194,226,228,230,234}; // Areas that are entirely restricted to water
internal static ReadOnlySpan<byte> InaccessibleRank12DistributionLocations => new byte[] {154,178,186,188,190,192,194,226,228,230,234}; // Areas that are entirely restricted to water
/// <summary>
/// Location IDs containing Dens that cannot be accessed without Rotom Bike's Water Mode.

View file

@ -16,9 +16,9 @@ internal static class EvolutionRestrictions
/// <summary>
/// List of species that evolve from a previous species having a move while leveling up
/// </summary>
private static readonly Dictionary<int, MoveEvolution> SpeciesEvolutionWithMove = new()
private static readonly Dictionary<ushort, MoveEvolution> SpeciesEvolutionWithMove = new()
{
{(int)Eevee, new(00, 0)}, // FairyMoves
{(int)Eevee, new()}, // FairyMoves
{(int)MimeJr, new(01, (int)Mimic)},
{(int)Bonsly, new(02, (int)Mimic)},
{(int)Aipom, new(03, (int)Mimic)},
@ -35,7 +35,7 @@ internal static class EvolutionRestrictions
{(int)Dunsparce, new(14, (int)HyperDrill)},
};
private readonly record struct MoveEvolution(int ReferenceIndex, ushort Move);
private readonly record struct MoveEvolution(byte ReferenceIndex, ushort Move);
private static readonly ushort[] FairyMoves =
{

View file

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
namespace PKHeX.Core;
@ -13,8 +14,10 @@ public static class RibbonStrings
/// Resets the Ribbon Dictionary to use the supplied set of Ribbon (Property) Names.
/// </summary>
/// <param name="lines">Array of strings that are tab separated with Property Name, \t, and Display Name.</param>
public static void ResetDictionary(IEnumerable<string> lines)
public static void ResetDictionary(ReadOnlySpan<string> lines)
{
RibbonNames.EnsureCapacity(lines.Length);
// Don't clear existing keys on reset; only update.
// A language will have the same keys (hopefully), only with differing values.
foreach (var line in lines)

View file

@ -193,7 +193,7 @@ public static class StringConverter12
#region Gen 1/2 Character Tables
internal static readonly Dictionary<byte, char> RBY2U_U = new()
internal static readonly Dictionary<byte, char> RBY2U_U = new(120)
{
{0x50, G1Terminator},
{0x5D, G1TradeOT},
@ -315,7 +315,7 @@ public static class StringConverter12
{0xFF, '9'},
};
private static readonly Dictionary<byte, char> RBY2U_J = new()
private static readonly Dictionary<byte, char> RBY2U_J = new(180)
{
{0x05, 'ガ'},
{0x06, 'ギ'},
@ -488,7 +488,7 @@ public static class StringConverter12
{0xFF, '9'},
};
internal static readonly Dictionary<char, byte> U2RBY_U = new()
internal static readonly Dictionary<char, byte> U2RBY_U = new(120)
{
{G1Terminator, 0x50},
{G1TradeOT, 0x5D}, // TRAINER (Localized per ROM)
@ -610,7 +610,7 @@ public static class StringConverter12
{'9', 0xFF},
};
private static readonly Dictionary<char, byte> U2RBY_J = new()
private static readonly Dictionary<char, byte> U2RBY_J = new(180)
{
{'ガ', 0x05},
{'ギ', 0x06},

View file

@ -138,21 +138,15 @@ public static class StringConverter2KOR
/// </summary>
/// <param name="nick">Generation 4 Species Name</param>
/// <returns>Localized Name for Generation 2</returns>
public static string LocalizeKOR2(string nick)
public static string LocalizeKOR2(string nick) => nick switch
{
if (KorG2Localized.TryGetValue(nick, out var localized))
return localized;
return nick;
}
private static readonly Dictionary<string, string> KorG2Localized = new()
{
{ "덩쿠리", "덩구리" }, // Tangela
{ "슈륙챙이", "수륙챙이" }, // Poliwhirl
"덩쿠리" => "덩구리", // Tangela
"슈륙챙이" => "수륙챙이", // Poliwhirl
_ => nick,
};
#region Gen 2 Korean Character Tables
private static readonly Dictionary<char, byte> U2GSC_KOR_0 = new()
private static readonly Dictionary<char, byte> U2GSC_KOR_0 = new(256)
{
{'ㄱ', 0x00}, {'ㄴ', 0x01}, {'ㄷ', 0x02}, {'ㄹ', 0x03}, {'ㅁ', 0x04}, {'ㅂ', 0x05}, {'ㅅ', 0x06}, {'ㅇ', 0x07}, {'ㅈ', 0x08}, {'ㅊ', 0x09}, {'ㅋ', 0x0A}, {'ㅌ', 0x0B}, {'ㅍ', 0x0C}, {'ㅎ', 0x0D}, {'ㄲ', 0x0E}, {'ㄸ', 0x0F},
{'ㅃ', 0x10}, {'ㅆ', 0x11}, {'ㅉ', 0x12},
@ -163,7 +157,7 @@ public static class StringConverter2KOR
{'\u3000', 0xFF},
};
private static readonly Dictionary<char, byte> U2GSC_KOR_1 = new()
private static readonly Dictionary<char, byte> U2GSC_KOR_1 = new(256)
{
{'가', 0x01}, {'각', 0x02}, {'간', 0x03}, {'갇', 0x04}, {'갈', 0x05}, {'갉', 0x06}, {'갊', 0x07}, {'감', 0x08}, {'갑', 0x09}, {'값', 0x0A}, {'갓', 0x0B}, {'갔', 0x0C}, {'강', 0x0D}, {'갖', 0x0E}, {'갗', 0x0F},
{'같', 0x10}, {'갚', 0x11}, {'갛', 0x12}, {'개', 0x13}, {'객', 0x14}, {'갠', 0x15}, {'갤', 0x16}, {'갬', 0x17}, {'갭', 0x18}, {'갯', 0x19}, {'갰', 0x1A}, {'갱', 0x1B}, {'갸', 0x1C}, {'갹', 0x1D}, {'갼', 0x1E}, {'걀', 0x1F},
@ -182,7 +176,7 @@ public static class StringConverter2KOR
{'꼭', 0xF0}, {'꼰', 0xF1}, {'꼲', 0xF2}, {'꼴', 0xF3}, {'꼼', 0xF4}, {'꼽', 0xF5}, {'꼿', 0xF6}, {'꽁', 0xF7}, {'꽂', 0xF8}, {'꽃', 0xF9}, {'꽈', 0xFA}, {'꽉', 0xFB}, {'꽐', 0xFC}, {'꽜', 0xFD}, {'꽝', 0xFE}, {'꽤', 0xFF},
};
private static readonly Dictionary<char, byte> U2GSC_KOR_2 = new()
private static readonly Dictionary<char, byte> U2GSC_KOR_2 = new(256)
{
{'꽥', 0x00}, {'꽹', 0x01}, {'꾀', 0x02}, {'꾄', 0x03}, {'꾈', 0x04}, {'꾐', 0x05}, {'꾑', 0x06}, {'꾕', 0x07}, {'꾜', 0x08}, {'꾸', 0x09}, {'꾹', 0x0A}, {'꾼', 0x0B}, {'꿀', 0x0C}, {'꿇', 0x0D}, {'꿈', 0x0E}, {'꿉', 0x0F},
{'꿋', 0x10}, {'꿍', 0x11}, {'꿎', 0x12}, {'꿔', 0x13}, {'꿜', 0x14}, {'꿨', 0x15}, {'꿩', 0x16}, {'꿰', 0x17}, {'꿱', 0x18}, {'꿴', 0x19}, {'꿸', 0x1A}, {'뀀', 0x1B}, {'뀁', 0x1C}, {'뀄', 0x1D}, {'뀌', 0x1E}, {'뀐', 0x1F},
@ -201,7 +195,7 @@ public static class StringConverter2KOR
{'댑', 0xF0}, {'댓', 0xF1}, {'댔', 0xF2}, {'댕', 0xF3}, {'더', 0xF5}, {'덕', 0xF6}, {'덖', 0xF7}, {'던', 0xF8}, {'덛', 0xF9}, {'덜', 0xFA}, {'덞', 0xFB}, {'덟', 0xFC}, {'덤', 0xFD}, {'덥', 0xFE},
};
private static readonly Dictionary<char, byte> U2GSC_KOR_3 = new()
private static readonly Dictionary<char, byte> U2GSC_KOR_3 = new(256)
{
{'덧', 0x01}, {'덩', 0x02}, {'덫', 0x03}, {'덮', 0x04}, {'데', 0x05}, {'덱', 0x06}, {'덴', 0x07}, {'델', 0x08}, {'뎀', 0x09}, {'뎁', 0x0A}, {'뎃', 0x0B}, {'뎄', 0x0C}, {'뎅', 0x0D}, {'뎌', 0x0E}, {'뎐', 0x0F},
{'뎔', 0x10}, {'뎠', 0x11}, {'뎡', 0x12}, {'뎨', 0x13}, {'뎬', 0x14}, {'도', 0x15}, {'독', 0x16}, {'돈', 0x17}, {'돋', 0x18}, {'돌', 0x19}, {'돎', 0x1A}, {'돔', 0x1C}, {'돕', 0x1D}, {'돗', 0x1E}, {'동', 0x1F},
@ -220,7 +214,7 @@ public static class StringConverter2KOR
{'렝', 0xF0}, {'려', 0xF1}, {'력', 0xF2}, {'련', 0xF3}, {'렬', 0xF4}, {'렴', 0xF5}, {'렵', 0xF6}, {'렷', 0xF7}, {'렸', 0xF8}, {'령', 0xF9}, {'례', 0xFA}, {'롄', 0xFB}, {'롑', 0xFC}, {'롓', 0xFD}, {'로', 0xFE}, {'록', 0xFF},
};
private static readonly Dictionary<char, byte> U2GSC_KOR_4 = new()
private static readonly Dictionary<char, byte> U2GSC_KOR_4 = new(256)
{
{'론', 0x00}, {'롤', 0x01}, {'롬', 0x02}, {'롭', 0x03}, {'롯', 0x04}, {'롱', 0x05}, {'롸', 0x06}, {'롼', 0x07}, {'뢍', 0x08}, {'뢨', 0x09}, {'뢰', 0x0A}, {'뢴', 0x0B}, {'뢸', 0x0C}, {'룀', 0x0D}, {'룁', 0x0E}, {'룃', 0x0F},
{'룅', 0x10}, {'료', 0x11}, {'룐', 0x12}, {'룔', 0x13}, {'룝', 0x14}, {'룟', 0x15}, {'룡', 0x16}, {'루', 0x17}, {'룩', 0x18}, {'룬', 0x19}, {'룰', 0x1A}, {'룸', 0x1B}, {'룹', 0x1C}, {'룻', 0x1D}, {'룽', 0x1E}, {'뤄', 0x1F},
@ -239,7 +233,7 @@ public static class StringConverter2KOR
{'뱅', 0xF0}, {'뱉', 0xF1}, {'뱌', 0xF2}, {'뱍', 0xF3}, {'뱐', 0xF4}, {'뱝', 0xF5}, {'버', 0xF6}, {'벅', 0xF7}, {'번', 0xF8}, {'벋', 0xF9}, {'벌', 0xFA}, {'벎', 0xFB}, {'범', 0xFC}, {'법', 0xFD}, {'벗', 0xFE},
};
private static readonly Dictionary<char, byte> U2GSC_KOR_5 = new()
private static readonly Dictionary<char, byte> U2GSC_KOR_5 = new(256)
{
{'벙', 0x01}, {'벚', 0x02}, {'베', 0x03}, {'벡', 0x04}, {'벤', 0x05}, {'벧', 0x06}, {'벨', 0x07}, {'벰', 0x08}, {'벱', 0x09}, {'벳', 0x0A}, {'벴', 0x0B}, {'벵', 0x0C}, {'벼', 0x0D}, {'벽', 0x0E}, {'변', 0x0F},
{'별', 0x10}, {'볍', 0x11}, {'볏', 0x12}, {'볐', 0x13}, {'병', 0x14}, {'볕', 0x15}, {'볘', 0x16}, {'볜', 0x17}, {'보', 0x18}, {'복', 0x19}, {'볶', 0x1A}, {'본', 0x1B}, {'볼', 0x1C}, {'봄', 0x1D}, {'봅', 0x1E}, {'봇', 0x1F},
@ -258,7 +252,7 @@ public static class StringConverter2KOR
{'셈', 0xF0}, {'셉', 0xF1}, {'셋', 0xF2}, {'셌', 0xF3}, {'셍', 0xF4}, {'셔', 0xF5}, {'셕', 0xF6}, {'션', 0xF7}, {'셜', 0xF8}, {'셤', 0xF9}, {'셥', 0xFA}, {'셧', 0xFB}, {'셨', 0xFC}, {'셩', 0xFD}, {'셰', 0xFE}, {'셴', 0xFF},
};
private static readonly Dictionary<char, byte> U2GSC_KOR_6 = new()
private static readonly Dictionary<char, byte> U2GSC_KOR_6 = new(256)
{
{'셸', 0x00}, {'솅', 0x01}, {'소', 0x02}, {'속', 0x03}, {'솎', 0x04}, {'손', 0x05}, {'솔', 0x06}, {'솖', 0x07}, {'솜', 0x08}, {'솝', 0x09}, {'솟', 0x0A}, {'송', 0x0B}, {'솥', 0x0C}, {'솨', 0x0D}, {'솩', 0x0E}, {'솬', 0x0F},
{'솰', 0x10}, {'솽', 0x11}, {'쇄', 0x12}, {'쇈', 0x13}, {'쇌', 0x14}, {'쇔', 0x15}, {'쇗', 0x16}, {'쇘', 0x17}, {'쇠', 0x18}, {'쇤', 0x19}, {'쇨', 0x1A}, {'쇰', 0x1B}, {'쇱', 0x1C}, {'쇳', 0x1D}, {'쇼', 0x1E}, {'쇽', 0x1F},
@ -277,7 +271,7 @@ public static class StringConverter2KOR
{'언', 0xF0}, {'얹', 0xF1}, {'얻', 0xF2}, {'얼', 0xF3}, {'얽', 0xF4}, {'얾', 0xF5}, {'엄', 0xF6}, {'업', 0xF7}, {'없', 0xF8}, {'엇', 0xF9}, {'었', 0xFA}, {'엉', 0xFB}, {'엊', 0xFC}, {'엌', 0xFD}, {'엎', 0xFE},
};
private static readonly Dictionary<char, byte> U2GSC_KOR_7 = new()
private static readonly Dictionary<char, byte> U2GSC_KOR_7 = new(256)
{
{'에', 0x01}, {'엑', 0x02}, {'엔', 0x03}, {'엘', 0x04}, {'엠', 0x05}, {'엡', 0x06}, {'엣', 0x07}, {'엥', 0x08}, {'여', 0x09}, {'역', 0x0A}, {'엮', 0x0B}, {'연', 0x0C}, {'열', 0x0D}, {'엶', 0x0E}, {'엷', 0x0F},
{'염', 0x10}, {'엽', 0x11}, {'엾', 0x12}, {'엿', 0x13}, {'였', 0x14}, {'영', 0x15}, {'옅', 0x16}, {'옆', 0x17}, {'옇', 0x18}, {'예', 0x19}, {'옌', 0x1A}, {'옐', 0x1B}, {'옘', 0x1C}, {'옙', 0x1D}, {'옛', 0x1E}, {'옜', 0x1F},
@ -296,7 +290,7 @@ public static class StringConverter2KOR
{'좇', 0xF0}, {'좋', 0xF1}, {'좌', 0xF2}, {'좍', 0xF3}, {'좔', 0xF4}, {'좝', 0xF5}, {'좟', 0xF6}, {'좡', 0xF7}, {'좨', 0xF8}, {'좼', 0xF9}, {'좽', 0xFA}, {'죄', 0xFB}, {'죈', 0xFC}, {'죌', 0xFD}, {'죔', 0xFE}, {'죕', 0xFF},
};
private static readonly Dictionary<char, byte> U2GSC_KOR_8 = new()
private static readonly Dictionary<char, byte> U2GSC_KOR_8 = new(256)
{
{'죗', 0x00}, {'죙', 0x01}, {'죠', 0x02}, {'죡', 0x03}, {'죤', 0x04}, {'죵', 0x05}, {'주', 0x06}, {'죽', 0x07}, {'준', 0x08}, {'줄', 0x09}, {'줅', 0x0A}, {'줆', 0x0B}, {'줌', 0x0C}, {'줍', 0x0D}, {'줏', 0x0E}, {'중', 0x0F},
{'줘', 0x10}, {'줬', 0x11}, {'줴', 0x12}, {'쥐', 0x13}, {'쥑', 0x14}, {'쥔', 0x15}, {'쥘', 0x16}, {'쥠', 0x17}, {'쥡', 0x18}, {'쥣', 0x19}, {'쥬', 0x1A}, {'쥰', 0x1B}, {'쥴', 0x1C}, {'쥼', 0x1D}, {'즈', 0x1E}, {'즉', 0x1F},
@ -315,7 +309,7 @@ public static class StringConverter2KOR
{'췻', 0xF0}, {'췽', 0xF1}, {'츄', 0xF2}, {'츈', 0xF3}, {'츌', 0xF4}, {'츔', 0xF5}, {'츙', 0xF6}, {'츠', 0xF7}, {'측', 0xF8}, {'츤', 0xF9}, {'츨', 0xFA}, {'츰', 0xFB}, {'츱', 0xFC}, {'츳', 0xFD}, {'층', 0xFE},
};
private static readonly Dictionary<char, byte> U2GSC_KOR_9 = new()
private static readonly Dictionary<char, byte> U2GSC_KOR_9 = new(256)
{
{'치', 0x01}, {'칙', 0x02}, {'친', 0x03}, {'칟', 0x04}, {'칠', 0x05}, {'칡', 0x06}, {'침', 0x07}, {'칩', 0x08}, {'칫', 0x09}, {'칭', 0x0A}, {'카', 0x0B}, {'칵', 0x0C}, {'칸', 0x0D}, {'칼', 0x0E}, {'캄', 0x0F},
{'캅', 0x10}, {'캇', 0x11}, {'캉', 0x12}, {'캐', 0x13}, {'캑', 0x14}, {'캔', 0x15}, {'캘', 0x16}, {'캠', 0x17}, {'캡', 0x18}, {'캣', 0x19}, {'캤', 0x1A}, {'캥', 0x1B}, {'캬', 0x1C}, {'캭', 0x1D}, {'컁', 0x1E}, {'커', 0x1F},
@ -334,7 +328,7 @@ public static class StringConverter2KOR
{'팀', 0xF0}, {'팁', 0xF1}, {'팃', 0xF2}, {'팅', 0xF3}, {'파', 0xF4}, {'팍', 0xF5}, {'팎', 0xF6}, {'판', 0xF7}, {'팔', 0xF8}, {'팖', 0xF9}, {'팜', 0xFA}, {'팝', 0xFB}, {'팟', 0xFC}, {'팠', 0xFD}, {'팡', 0xFE}, {'팥', 0xFF},
};
private static readonly Dictionary<char, byte> U2GSC_KOR_A = new()
private static readonly Dictionary<char, byte> U2GSC_KOR_A = new(256)
{
{'패', 0x00}, {'팩', 0x01}, {'팬', 0x02}, {'팰', 0x03}, {'팸', 0x04}, {'팹', 0x05}, {'팻', 0x06}, {'팼', 0x07}, {'팽', 0x08}, {'퍄', 0x09}, {'퍅', 0x0A}, {'퍼', 0x0B}, {'퍽', 0x0C}, {'펀', 0x0D}, {'펄', 0x0E}, {'펌', 0x0F},
{'펍', 0x10}, {'펏', 0x11}, {'펐', 0x12}, {'펑', 0x13}, {'페', 0x14}, {'펙', 0x15}, {'펜', 0x16}, {'펠', 0x17}, {'펨', 0x18}, {'펩', 0x19}, {'펫', 0x1A}, {'펭', 0x1B}, {'펴', 0x1C}, {'편', 0x1D}, {'펼', 0x1E}, {'폄', 0x1F},
@ -355,7 +349,7 @@ public static class StringConverter2KOR
private static readonly Dictionary<char, byte> U2GSC_KOR_B = U2GSC_KOR_0;
private static readonly Dictionary<byte, char> GSC2U_KOR_0 = new()
private static readonly Dictionary<byte, char> GSC2U_KOR_0 = new(80)
{
{0x00, 'ㄱ'}, {0x01, 'ㄴ'}, {0x02, 'ㄷ'}, {0x03, 'ㄹ'}, {0x04, 'ㅁ'}, {0x05, 'ㅂ'}, {0x06, 'ㅅ'}, {0x07, 'ㅇ'}, {0x08, 'ㅈ'}, {0x09, 'ㅊ'}, {0x0A, 'ㅋ'}, {0x0B, 'ㅌ'}, {0x0C, 'ㅍ'}, {0x0D, 'ㅎ'}, {0x0E, 'ㄲ'}, {0x0F, 'ㄸ'},
{0x10, 'ㅃ'}, {0x11, 'ㅆ'}, {0x12, 'ㅉ'},
@ -366,7 +360,7 @@ public static class StringConverter2KOR
{0xFF, '\u3000'},
};
private static readonly Dictionary<byte, char> GSC2U_KOR_1 = new()
private static readonly Dictionary<byte, char> GSC2U_KOR_1 = new(256)
{
{0x01, '가'}, {0x02, '각'}, {0x03, '간'}, {0x04, '갇'}, {0x05, '갈'}, {0x06, '갉'}, {0x07, '갊'}, {0x08, '감'}, {0x09, '갑'}, {0x0A, '값'}, {0x0B, '갓'}, {0x0C, '갔'}, {0x0D, '강'}, {0x0E, '갖'}, {0x0F, '갗'},
{0x10, '같'}, {0x11, '갚'}, {0x12, '갛'}, {0x13, '개'}, {0x14, '객'}, {0x15, '갠'}, {0x16, '갤'}, {0x17, '갬'}, {0x18, '갭'}, {0x19, '갯'}, {0x1A, '갰'}, {0x1B, '갱'}, {0x1C, '갸'}, {0x1D, '갹'}, {0x1E, '갼'}, {0x1F, '걀'},
@ -385,7 +379,7 @@ public static class StringConverter2KOR
{0xF0, '꼭'}, {0xF1, '꼰'}, {0xF2, '꼲'}, {0xF3, '꼴'}, {0xF4, '꼼'}, {0xF5, '꼽'}, {0xF6, '꼿'}, {0xF7, '꽁'}, {0xF8, '꽂'}, {0xF9, '꽃'}, {0xFA, '꽈'}, {0xFB, '꽉'}, {0xFC, '꽐'}, {0xFD, '꽜'}, {0xFE, '꽝'}, {0xFF, '꽤'},
};
private static readonly Dictionary<byte, char> GSC2U_KOR_2 = new()
private static readonly Dictionary<byte, char> GSC2U_KOR_2 = new(256)
{
{0x00, '꽥'}, {0x01, '꽹'}, {0x02, '꾀'}, {0x03, '꾄'}, {0x04, '꾈'}, {0x05, '꾐'}, {0x06, '꾑'}, {0x07, '꾕'}, {0x08, '꾜'}, {0x09, '꾸'}, {0x0A, '꾹'}, {0x0B, '꾼'}, {0x0C, '꿀'}, {0x0D, '꿇'}, {0x0E, '꿈'}, {0x0F, '꿉'},
{0x10, '꿋'}, {0x11, '꿍'}, {0x12, '꿎'}, {0x13, '꿔'}, {0x14, '꿜'}, {0x15, '꿨'}, {0x16, '꿩'}, {0x17, '꿰'}, {0x18, '꿱'}, {0x19, '꿴'}, {0x1A, '꿸'}, {0x1B, '뀀'}, {0x1C, '뀁'}, {0x1D, '뀄'}, {0x1E, '뀌'}, {0x1F, '뀐'},
@ -404,7 +398,7 @@ public static class StringConverter2KOR
{0xF0, '댑'}, {0xF1, '댓'}, {0xF2, '댔'}, {0xF3, '댕'}, {0xF5, '더'}, {0xF6, '덕'}, {0xF7, '덖'}, {0xF8, '던'}, {0xF9, '덛'}, {0xFA, '덜'}, {0xFB, '덞'}, {0xFC, '덟'}, {0xFD, '덤'}, {0xFE, '덥'},
};
private static readonly Dictionary<byte, char> GSC2U_KOR_3 = new()
private static readonly Dictionary<byte, char> GSC2U_KOR_3 = new(256)
{
{0x01, '덧'}, {0x02, '덩'}, {0x03, '덫'}, {0x04, '덮'}, {0x05, '데'}, {0x06, '덱'}, {0x07, '덴'}, {0x08, '델'}, {0x09, '뎀'}, {0x0A, '뎁'}, {0x0B, '뎃'}, {0x0C, '뎄'}, {0x0D, '뎅'}, {0x0E, '뎌'}, {0x0F, '뎐'},
{0x10, '뎔'}, {0x11, '뎠'}, {0x12, '뎡'}, {0x13, '뎨'}, {0x14, '뎬'}, {0x15, '도'}, {0x16, '독'}, {0x17, '돈'}, {0x18, '돋'}, {0x19, '돌'}, {0x1A, '돎'}, {0x1C, '돔'}, {0x1D, '돕'}, {0x1E, '돗'}, {0x1F, '동'},
@ -423,7 +417,7 @@ public static class StringConverter2KOR
{0xF0, '렝'}, {0xF1, '려'}, {0xF2, '력'}, {0xF3, '련'}, {0xF4, '렬'}, {0xF5, '렴'}, {0xF6, '렵'}, {0xF7, '렷'}, {0xF8, '렸'}, {0xF9, '령'}, {0xFA, '례'}, {0xFB, '롄'}, {0xFC, '롑'}, {0xFD, '롓'}, {0xFE, '로'}, {0xFF, '록'},
};
private static readonly Dictionary<byte, char> GSC2U_KOR_4 = new()
private static readonly Dictionary<byte, char> GSC2U_KOR_4 = new(256)
{
{0x00, '론'}, {0x01, '롤'}, {0x02, '롬'}, {0x03, '롭'}, {0x04, '롯'}, {0x05, '롱'}, {0x06, '롸'}, {0x07, '롼'}, {0x08, '뢍'}, {0x09, '뢨'}, {0x0A, '뢰'}, {0x0B, '뢴'}, {0x0C, '뢸'}, {0x0D, '룀'}, {0x0E, '룁'}, {0x0F, '룃'},
{0x10, '룅'}, {0x11, '료'}, {0x12, '룐'}, {0x13, '룔'}, {0x14, '룝'}, {0x15, '룟'}, {0x16, '룡'}, {0x17, '루'}, {0x18, '룩'}, {0x19, '룬'}, {0x1A, '룰'}, {0x1B, '룸'}, {0x1C, '룹'}, {0x1D, '룻'}, {0x1E, '룽'}, {0x1F, '뤄'},
@ -442,7 +436,7 @@ public static class StringConverter2KOR
{0xF0, '뱅'}, {0xF1, '뱉'}, {0xF2, '뱌'}, {0xF3, '뱍'}, {0xF4, '뱐'}, {0xF5, '뱝'}, {0xF6, '버'}, {0xF7, '벅'}, {0xF8, '번'}, {0xF9, '벋'}, {0xFA, '벌'}, {0xFB, '벎'}, {0xFC, '범'}, {0xFD, '법'}, {0xFE, '벗'},
};
private static readonly Dictionary<byte, char> GSC2U_KOR_5 = new()
private static readonly Dictionary<byte, char> GSC2U_KOR_5 = new(256)
{
{0x01, '벙'}, {0x02, '벚'}, {0x03, '베'}, {0x04, '벡'}, {0x05, '벤'}, {0x06, '벧'}, {0x07, '벨'}, {0x08, '벰'}, {0x09, '벱'}, {0x0A, '벳'}, {0x0B, '벴'}, {0x0C, '벵'}, {0x0D, '벼'}, {0x0E, '벽'}, {0x0F, '변'},
{0x10, '별'}, {0x11, '볍'}, {0x12, '볏'}, {0x13, '볐'}, {0x14, '병'}, {0x15, '볕'}, {0x16, '볘'}, {0x17, '볜'}, {0x18, '보'}, {0x19, '복'}, {0x1A, '볶'}, {0x1B, '본'}, {0x1C, '볼'}, {0x1D, '봄'}, {0x1E, '봅'}, {0x1F, '봇'},
@ -461,7 +455,7 @@ public static class StringConverter2KOR
{0xF0, '셈'}, {0xF1, '셉'}, {0xF2, '셋'}, {0xF3, '셌'}, {0xF4, '셍'}, {0xF5, '셔'}, {0xF6, '셕'}, {0xF7, '션'}, {0xF8, '셜'}, {0xF9, '셤'}, {0xFA, '셥'}, {0xFB, '셧'}, {0xFC, '셨'}, {0xFD, '셩'}, {0xFE, '셰'}, {0xFF, '셴'},
};
private static readonly Dictionary<byte, char> GSC2U_KOR_6 = new()
private static readonly Dictionary<byte, char> GSC2U_KOR_6 = new(256)
{
{0x00, '셸'}, {0x01, '솅'}, {0x02, '소'}, {0x03, '속'}, {0x04, '솎'}, {0x05, '손'}, {0x06, '솔'}, {0x07, '솖'}, {0x08, '솜'}, {0x09, '솝'}, {0x0A, '솟'}, {0x0B, '송'}, {0x0C, '솥'}, {0x0D, '솨'}, {0x0E, '솩'}, {0x0F, '솬'},
{0x10, '솰'}, {0x11, '솽'}, {0x12, '쇄'}, {0x13, '쇈'}, {0x14, '쇌'}, {0x15, '쇔'}, {0x16, '쇗'}, {0x17, '쇘'}, {0x18, '쇠'}, {0x19, '쇤'}, {0x1A, '쇨'}, {0x1B, '쇰'}, {0x1C, '쇱'}, {0x1D, '쇳'}, {0x1E, '쇼'}, {0x1F, '쇽'},
@ -480,7 +474,7 @@ public static class StringConverter2KOR
{0xF0, '언'}, {0xF1, '얹'}, {0xF2, '얻'}, {0xF3, '얼'}, {0xF4, '얽'}, {0xF5, '얾'}, {0xF6, '엄'}, {0xF7, '업'}, {0xF8, '없'}, {0xF9, '엇'}, {0xFA, '었'}, {0xFB, '엉'}, {0xFC, '엊'}, {0xFD, '엌'}, {0xFE, '엎'},
};
private static readonly Dictionary<byte, char> GSC2U_KOR_7 = new()
private static readonly Dictionary<byte, char> GSC2U_KOR_7 = new(256)
{
{0x01, '에'}, {0x02, '엑'}, {0x03, '엔'}, {0x04, '엘'}, {0x05, '엠'}, {0x06, '엡'}, {0x07, '엣'}, {0x08, '엥'}, {0x09, '여'}, {0x0A, '역'}, {0x0B, '엮'}, {0x0C, '연'}, {0x0D, '열'}, {0x0E, '엶'}, {0x0F, '엷'},
{0x10, '염'}, {0x11, '엽'}, {0x12, '엾'}, {0x13, '엿'}, {0x14, '였'}, {0x15, '영'}, {0x16, '옅'}, {0x17, '옆'}, {0x18, '옇'}, {0x19, '예'}, {0x1A, '옌'}, {0x1B, '옐'}, {0x1C, '옘'}, {0x1D, '옙'}, {0x1E, '옛'}, {0x1F, '옜'},
@ -499,7 +493,7 @@ public static class StringConverter2KOR
{0xF0, '좇'}, {0xF1, '좋'}, {0xF2, '좌'}, {0xF3, '좍'}, {0xF4, '좔'}, {0xF5, '좝'}, {0xF6, '좟'}, {0xF7, '좡'}, {0xF8, '좨'}, {0xF9, '좼'}, {0xFA, '좽'}, {0xFB, '죄'}, {0xFC, '죈'}, {0xFD, '죌'}, {0xFE, '죔'}, {0xFF, '죕'},
};
private static readonly Dictionary<byte, char> GSC2U_KOR_8 = new()
private static readonly Dictionary<byte, char> GSC2U_KOR_8 = new(256)
{
{0x00, '죗'}, {0x01, '죙'}, {0x02, '죠'}, {0x03, '죡'}, {0x04, '죤'}, {0x05, '죵'}, {0x06, '주'}, {0x07, '죽'}, {0x08, '준'}, {0x09, '줄'}, {0x0A, '줅'}, {0x0B, '줆'}, {0x0C, '줌'}, {0x0D, '줍'}, {0x0E, '줏'}, {0x0F, '중'},
{0x10, '줘'}, {0x11, '줬'}, {0x12, '줴'}, {0x13, '쥐'}, {0x14, '쥑'}, {0x15, '쥔'}, {0x16, '쥘'}, {0x17, '쥠'}, {0x18, '쥡'}, {0x19, '쥣'}, {0x1A, '쥬'}, {0x1B, '쥰'}, {0x1C, '쥴'}, {0x1D, '쥼'}, {0x1E, '즈'}, {0x1F, '즉'},
@ -518,7 +512,7 @@ public static class StringConverter2KOR
{0xF0, '췻'}, {0xF1, '췽'}, {0xF2, '츄'}, {0xF3, '츈'}, {0xF4, '츌'}, {0xF5, '츔'}, {0xF6, '츙'}, {0xF7, '츠'}, {0xF8, '측'}, {0xF9, '츤'}, {0xFA, '츨'}, {0xFB, '츰'}, {0xFC, '츱'}, {0xFD, '츳'}, {0xFE, '층'},
};
private static readonly Dictionary<byte, char> GSC2U_KOR_9 = new()
private static readonly Dictionary<byte, char> GSC2U_KOR_9 = new(256)
{
{0x01, '치'}, {0x02, '칙'}, {0x03, '친'}, {0x04, '칟'}, {0x05, '칠'}, {0x06, '칡'}, {0x07, '침'}, {0x08, '칩'}, {0x09, '칫'}, {0x0A, '칭'}, {0x0B, '카'}, {0x0C, '칵'}, {0x0D, '칸'}, {0x0E, '칼'}, {0x0F, '캄'},
{0x10, '캅'}, {0x11, '캇'}, {0x12, '캉'}, {0x13, '캐'}, {0x14, '캑'}, {0x15, '캔'}, {0x16, '캘'}, {0x17, '캠'}, {0x18, '캡'}, {0x19, '캣'}, {0x1A, '캤'}, {0x1B, '캥'}, {0x1C, '캬'}, {0x1D, '캭'}, {0x1E, '컁'}, {0x1F, '커'},
@ -537,7 +531,7 @@ public static class StringConverter2KOR
{0xF0, '팀'}, {0xF1, '팁'}, {0xF2, '팃'}, {0xF3, '팅'}, {0xF4, '파'}, {0xF5, '팍'}, {0xF6, '팎'}, {0xF7, '판'}, {0xF8, '팔'}, {0xF9, '팖'}, {0xFA, '팜'}, {0xFB, '팝'}, {0xFC, '팟'}, {0xFD, '팠'}, {0xFE, '팡'}, {0xFF, '팥'},
};
private static readonly Dictionary<byte, char> GSC2U_KOR_A = new()
private static readonly Dictionary<byte, char> GSC2U_KOR_A = new(256)
{
{0x00, '패'}, {0x01, '팩'}, {0x02, '팬'}, {0x03, '팰'}, {0x04, '팸'}, {0x05, '팹'}, {0x06, '팻'}, {0x07, '팼'}, {0x08, '팽'}, {0x09, '퍄'}, {0x0A, '퍅'}, {0x0B, '퍼'}, {0x0C, '퍽'}, {0x0D, '펀'}, {0x0E, '펄'}, {0x0F, '펌'},
{0x10, '펍'}, {0x11, '펏'}, {0x12, '펐'}, {0x13, '펑'}, {0x14, '페'}, {0x15, '펙'}, {0x16, '펜'}, {0x17, '펠'}, {0x18, '펨'}, {0x19, '펩'}, {0x1A, '펫'}, {0x1B, '펭'}, {0x1C, '펴'}, {0x1D, '편'}, {0x1E, '펼'}, {0x1F, '폄'},

View file

@ -131,65 +131,76 @@ public sealed class Zukan7b : Zukan7
span[3] = 0;
}
private const int EntryMeltan = 151; // Melmetal 152
private const int EntryForms = 153;
public static bool TryGetSizeEntryIndex(ushort species, byte form, out int index)
{
index = -1;
if (form == 0 && species <= 151)
if (form == 0)
{
index = species - 1;
return true;
if (species <= 151) // Mew
{
index = species - 1;
return true;
}
if (species is 808 or 809) // Meltan & Melmetal
{
index = EntryMeltan + (species - 808);
return true;
}
return false;
}
for (int i = 0; i < SizeDexInfoTable.Length; i += 3)
// Forms
for (int i = 0; i < SizeDexInfoTable.Length; i += 2)
{
if (SizeDexInfoTable[i] != species)
continue;
if (SizeDexInfoTable[i + 1] != form)
continue;
index = SizeDexInfoTable[i + 2];
index = EntryForms + (i >> 1);
return true;
}
return false;
}
private static readonly ushort[] SizeDexInfoTable =
private static ReadOnlySpan<byte> SizeDexInfoTable => new byte[]
{
// species, form, index
808, 0, 151,
809, 0, 152,
003, 1, 153,
006, 1, 154,
006, 2, 155,
009, 1, 156,
015, 1, 157,
018, 1, 158,
019, 1, 159,
020, 1, 160,
026, 1, 161,
027, 1, 162,
028, 1, 163,
037, 1, 164,
038, 1, 165,
050, 1, 166,
051, 1, 167,
052, 1, 168,
053, 1, 169,
065, 1, 170,
074, 1, 171,
075, 1, 172,
076, 1, 173,
080, 1, 174,
088, 1, 175,
089, 1, 176,
094, 1, 177,
103, 1, 178,
105, 1, 179,
115, 1, 180,
127, 1, 181,
130, 1, 182,
142, 1, 183,
150, 1, 184,
150, 2, 185,
// species, form
003, 1,
006, 1,
006, 2,
009, 1,
015, 1,
018, 1,
019, 1,
020, 1,
026, 1,
027, 1,
028, 1,
037, 1,
038, 1,
050, 1,
051, 1,
052, 1,
053, 1,
065, 1,
074, 1,
075, 1,
076, 1,
080, 1,
088, 1,
089, 1,
094, 1,
103, 1,
105, 1,
115, 1,
127, 1,
130, 1,
142, 1,
150, 1,
150, 2,
};
protected override bool GetSaneFormsToIterate(ushort species, out int formStart, out int formEnd, int formIn)