From 274b613487f87650a9fd8f981ecbde20273b5254 Mon Sep 17 00:00:00 2001 From: Kurt <kaphotics@gmail.com> Date: Fri, 8 Apr 2022 20:43:31 -0700 Subject: [PATCH] Change signature to set stackalloc ivs --- .../Saves/Substructures/Gen3/Roamer3.cs | 19 +++++++++++++------ .../Subforms/Save Editors/Gen3/SAV_Roamer3.cs | 4 ++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/PKHeX.Core/Saves/Substructures/Gen3/Roamer3.cs b/PKHeX.Core/Saves/Substructures/Gen3/Roamer3.cs index c4d9f2889..3856a6e9c 100644 --- a/PKHeX.Core/Saves/Substructures/Gen3/Roamer3.cs +++ b/PKHeX.Core/Saves/Substructures/Gen3/Roamer3.cs @@ -76,12 +76,19 @@ namespace PKHeX.Core public int[] IVs { get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; - set - { - if (value.Length != 6) return; - IV_HP = value[0]; IV_ATK = value[1]; IV_DEF = value[2]; - IV_SPE = value[3]; IV_SPA = value[4]; IV_SPD = value[5]; - } + set => SetIVs(value); + } + + public void SetIVs(ReadOnlySpan<int> value) + { + if (value.Length != 6) + return; + IV_HP = value[0]; + IV_ATK = value[1]; + IV_DEF = value[2]; + IV_SPE = value[3]; + IV_SPA = value[4]; + IV_SPD = value[5]; } /// <summary> diff --git a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.cs b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.cs index b436cac04..6ea2760d6 100644 --- a/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.cs +++ b/PKHeX.WinForms/Subforms/Save Editors/Gen3/SAV_Roamer3.cs @@ -38,14 +38,14 @@ namespace PKHeX.WinForms private void SaveData() { - int[] IVs = new int[6]; + Span<int> IVs = stackalloc int[6]; var iv = new[] { TB_HPIV, TB_ATKIV, TB_DEFIV, TB_SPEIV, TB_SPAIV, TB_SPDIV }; for (int i = 0; i < iv.Length; i++) IVs[i] = Util.ToInt32(iv[i].Text); Reader.PID = Util.GetHexValue(TB_PID.Text); Reader.Species = WinFormsUtil.GetIndex(CB_Species); - Reader.IVs = IVs; + Reader.SetIVs(IVs); Reader.Active = CHK_Active.Checked; Reader.CurrentLevel = (int)NUD_Level.Value; }