Skip to content

Commit

Permalink
Avoid zero-length array allocations (#427)
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-carvalho authored Dec 22, 2024
1 parent decd37c commit 5913ced
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Ryujinx.HLE/HOS/Horizon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public void ScanAmiibo(int nfpDeviceId, string amiiboId, bool useRandomUuid)
{
if (VirtualAmiibo.ApplicationBytes.Length > 0)
{
VirtualAmiibo.ApplicationBytes = new byte[0];
VirtualAmiibo.ApplicationBytes = Array.Empty<byte>();
VirtualAmiibo.InputBin = string.Empty;
}
if (NfpDevices[nfpDeviceId].State == NfpDeviceState.SearchingForTag)
Expand All @@ -356,7 +356,7 @@ public void ScanAmiiboFromBin(string path)
VirtualAmiibo.InputBin = path;
if (VirtualAmiibo.ApplicationBytes.Length > 0)
{
VirtualAmiibo.ApplicationBytes = new byte[0];
VirtualAmiibo.ApplicationBytes = Array.Empty<byte>();
}
byte[] encryptedData = File.ReadAllBytes(path);
VirtualAmiiboFile newFile = AmiiboBinReader.ReadBinFile(encryptedData);
Expand Down
4 changes: 2 additions & 2 deletions src/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp
static class VirtualAmiibo
{
public static uint OpenedApplicationAreaId;
public static byte[] ApplicationBytes = new byte[0];
public static byte[] ApplicationBytes = Array.Empty<byte>();
public static string InputBin = string.Empty;
public static string NickName = string.Empty;
private static readonly AmiiboJsonSerializerContext _serializerContext = AmiiboJsonSerializerContext.Default;
Expand Down Expand Up @@ -137,7 +137,7 @@ public static byte[] GetApplicationArea(string amiiboId)
if (ApplicationBytes.Length > 0)
{
byte[] bytes = ApplicationBytes;
ApplicationBytes = new byte[0];
ApplicationBytes = Array.Empty<byte>();
return bytes;
}
VirtualAmiiboFile virtualAmiiboFile = LoadAmiiboFile(amiiboId);
Expand Down

0 comments on commit 5913ced

Please sign in to comment.