PKM: Reduce allocation via in-place decryption logic (#4764)

This commit is contained in:
Kurt
2026-03-24 21:31:59 -05:00
committed by GitHub
parent 793525875f
commit 5bf1e2cf45
81 changed files with 882 additions and 759 deletions

View File

@@ -224,7 +224,7 @@ private void ClickDelete(object sender, EventArgs e)
{
// Data from Box: Delete from save file
var exist = b.Read(SAV);
if (!exist.DecryptedBoxData.SequenceEqual(pk.DecryptedBoxData)) // data modified already?
if (!exist.EqualsStored(pk)) // data modified already?
{
WinFormsUtil.Error(MsgDBDeleteFailModified, MsgDBDeleteFailWarning);
return;
@@ -263,7 +263,9 @@ private void ClickSet(object sender, EventArgs e)
return;
}
File.WriteAllBytes(path, pk.DecryptedBoxData);
Span<byte> data = stackalloc byte[pk.SIZE_STORED];
pk.WriteDecryptedDataStored(data);
File.WriteAllBytes(path, data);
var info = new SlotInfoFileSingle(path);
var entry = new SlotCache(info, pk);
@@ -446,8 +448,14 @@ private void Menu_Export_Click(object sender, EventArgs e)
string path = fbd.SelectedPath;
Directory.CreateDirectory(path);
Span<byte> data = stackalloc byte[SAV.SIZE_PARTY];
foreach (var pk in Results.Select(z => z.Entity))
File.WriteAllBytes(Path.Combine(path, PathUtil.CleanFileName(pk.FileName)), pk.DecryptedPartyData);
{
var fileName = Path.Combine(path, PathUtil.CleanFileName(pk.FileName));
pk.ForcePartyData();
pk.WriteDecryptedDataParty(data);
File.WriteAllBytes(fileName, data);
}
}
private void Menu_Import_Click(object sender, EventArgs e)