mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-14 09:35:15 -05:00
PKM: Reduce allocation via in-place decryption logic (#4764)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user