From c40c3905e2836e8b105406430c33659a84c2e3ca Mon Sep 17 00:00:00 2001 From: Berkan Diler Date: Wed, 19 Oct 2022 01:31:34 +0200 Subject: 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 --- Ryujinx.HLE/HOS/Tamper/InstructionHelper.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Ryujinx.HLE/HOS/Tamper') diff --git a/Ryujinx.HLE/HOS/Tamper/InstructionHelper.cs b/Ryujinx.HLE/HOS/Tamper/InstructionHelper.cs index d34f4cf8..e85d99c7 100644 --- a/Ryujinx.HLE/HOS/Tamper/InstructionHelper.cs +++ b/Ryujinx.HLE/HOS/Tamper/InstructionHelper.cs @@ -122,9 +122,8 @@ namespace Ryujinx.HLE.HOS.Tamper for (int nybbleIndex = 0; nybbleIndex < wordSize; nybbleIndex++) { int index = wordIndex * wordSize + nybbleIndex; - string byteData = word.Substring(nybbleIndex, 1); - instruction[index] = byte.Parse(byteData, NumberStyles.HexNumber, CultureInfo.InvariantCulture); + instruction[index] = byte.Parse(word.AsSpan(nybbleIndex, 1), NumberStyles.HexNumber, CultureInfo.InvariantCulture); } } -- cgit v1.2.3