From d751da84f941e0d089040cb7aad2c1b3224ae6b7 Mon Sep 17 00:00:00 2001 From: Berkan Diler Date: Wed, 16 Nov 2022 20:30:12 +0100 Subject: [PATCH] Use new C# 11 u8 string literals (#3854) --- Ryujinx.Audio/Renderer/Utils/FileHardwareDevice.cs | 8 ++++---- Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs | 2 +- .../HOS/Services/Nifm/StaticService/IGeneralService.cs | 2 +- Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs | 2 +- Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Ryujinx.Audio/Renderer/Utils/FileHardwareDevice.cs b/Ryujinx.Audio/Renderer/Utils/FileHardwareDevice.cs index 830b36ee..d49313ea 100644 --- a/Ryujinx.Audio/Renderer/Utils/FileHardwareDevice.cs +++ b/Ryujinx.Audio/Renderer/Utils/FileHardwareDevice.cs @@ -34,10 +34,10 @@ namespace Ryujinx.Audio.Renderer.Utils writer.Seek(0, SeekOrigin.Begin); - writer.Write(Encoding.ASCII.GetBytes("RIFF")); + writer.Write("RIFF"u8); writer.Write((int)(writer.BaseStream.Length - 8)); - writer.Write(Encoding.ASCII.GetBytes("WAVE")); - writer.Write(Encoding.ASCII.GetBytes("fmt ")); + writer.Write("WAVE"u8); + writer.Write("fmt "u8); writer.Write(16); writer.Write((short)1); writer.Write((short)GetChannelCount()); @@ -45,7 +45,7 @@ namespace Ryujinx.Audio.Renderer.Utils writer.Write(GetSampleRate() * GetChannelCount() * sizeof(short)); writer.Write((short)(GetChannelCount() * sizeof(short))); writer.Write((short)(sizeof(short) * 8)); - writer.Write(Encoding.ASCII.GetBytes("data")); + writer.Write("data"u8); writer.Write((int)(writer.BaseStream.Length - HeaderSize)); writer.Seek((int)currentPos, SeekOrigin.Begin); diff --git a/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs b/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs index 4e445c4f..4fdeadcb 100644 --- a/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs +++ b/Ryujinx.HLE/HOS/Services/Nfc/Nfp/VirtualAmiibo.cs @@ -85,7 +85,7 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp Reserved1 = new Array64(), Reserved2 = new Array58() }; - Encoding.ASCII.GetBytes("Ryujinx").CopyTo(registerInfo.Nickname.AsSpan()); + "Ryujinx"u8.CopyTo(registerInfo.Nickname.AsSpan()); return registerInfo; } diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs index 4a0259e6..bc70750d 100644 --- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs +++ b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs @@ -84,7 +84,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService networkProfile.IpSettingData.IpAddressSetting = new IpAddressSetting(interfaceProperties, unicastAddress); networkProfile.IpSettingData.DnsSetting = new DnsSetting(interfaceProperties); - Encoding.ASCII.GetBytes("RyujinxNetwork").CopyTo(networkProfile.Name.AsSpan()); + "RyujinxNetwork"u8.CopyTo(networkProfile.Name.AsSpan()); context.Memory.Write(networkProfileDataPosition, networkProfile); diff --git a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs index 3b13b583..12f6e90d 100644 --- a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs +++ b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs @@ -39,7 +39,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone new int[] { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } }; - private static readonly byte[] TimeZoneDefaultRule = Encoding.ASCII.GetBytes(",M4.1.0,M10.5.0"); + private static ReadOnlySpan TimeZoneDefaultRule => ",M4.1.0,M10.5.0"u8; [StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x10)] private struct CalendarTimeInternal diff --git a/Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs b/Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs index de50c6eb..510fec05 100644 --- a/Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs +++ b/Ryujinx.HLE/Loaders/Mods/IPSPatcher.cs @@ -20,10 +20,10 @@ namespace Ryujinx.HLE.Loaders.Mods private static MemPatch ParseIps(BinaryReader reader) { - Span IpsHeaderMagic = Encoding.ASCII.GetBytes("PATCH").AsSpan(); - Span IpsTailMagic = Encoding.ASCII.GetBytes("EOF").AsSpan(); - Span Ips32HeaderMagic = Encoding.ASCII.GetBytes("IPS32").AsSpan(); - Span Ips32TailMagic = Encoding.ASCII.GetBytes("EEOF").AsSpan(); + ReadOnlySpan IpsHeaderMagic = "PATCH"u8; + ReadOnlySpan IpsTailMagic = "EOF"u8; + ReadOnlySpan Ips32HeaderMagic = "IPS32"u8; + ReadOnlySpan Ips32TailMagic = "EEOF"u8; MemPatch patches = new MemPatch(); var header = reader.ReadBytes(IpsHeaderMagic.Length).AsSpan(); @@ -34,7 +34,7 @@ namespace Ryujinx.HLE.Loaders.Mods } bool is32; - Span tailSpan; + ReadOnlySpan tailSpan; if (header.SequenceEqual(IpsHeaderMagic)) {