diff options
| author | Berkan Diler <b.diler@gmx.de> | 2022-10-19 01:31:34 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-18 23:31:34 +0000 |
| commit | c40c3905e2836e8b105406430c33659a84c2e3ca (patch) | |
| tree | 4a1ed99ae42fc57a0d6288680a319e594729a18d /Ryujinx.HLE/HOS/Services | |
| parent | a6cd044f0f675ee0bd9d3954228bbd3f2f992a22 (diff) | |
Avoid allocations in .Parse methods (#3760)
* Avoid allocations in .Parse methods
Use the Span overloads of the Parse methods when possible to avoid string allocations and remove one unnecessarry array allocation
* Avoid another string allocation
Diffstat (limited to 'Ryujinx.HLE/HOS/Services')
| -rw-r--r-- | Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs b/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs index 9dfa677c..fc0c0647 100644 --- a/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs +++ b/Ryujinx.HLE/HOS/Services/Nfc/Nfp/NfpManager/INfp.cs @@ -816,11 +816,11 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp Reserved = new Array57<byte>() }; - modelInfo.CharacterId = BinaryPrimitives.ReverseEndianness(ushort.Parse(context.Device.System.NfpDevices[i].AmiiboId.Substring(0, 4), NumberStyles.HexNumber)); - modelInfo.CharacterVariant = byte.Parse(context.Device.System.NfpDevices[i].AmiiboId.Substring(4, 2), NumberStyles.HexNumber); - modelInfo.Series = byte.Parse(context.Device.System.NfpDevices[i].AmiiboId.Substring(12, 2), NumberStyles.HexNumber); - modelInfo.ModelNumber = ushort.Parse(context.Device.System.NfpDevices[i].AmiiboId.Substring(8, 4), NumberStyles.HexNumber); - modelInfo.Type = byte.Parse(context.Device.System.NfpDevices[i].AmiiboId.Substring(6, 2), NumberStyles.HexNumber); + modelInfo.CharacterId = BinaryPrimitives.ReverseEndianness(ushort.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(0, 4), NumberStyles.HexNumber)); + modelInfo.CharacterVariant = byte.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(4, 2), NumberStyles.HexNumber); + modelInfo.Series = byte.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(12, 2), NumberStyles.HexNumber); + modelInfo.ModelNumber = ushort.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(8, 4), NumberStyles.HexNumber); + modelInfo.Type = byte.Parse(context.Device.System.NfpDevices[i].AmiiboId.AsSpan(6, 2), NumberStyles.HexNumber); context.Memory.Write(outputPosition, modelInfo); |
