diff --git a/src/ARMeilleure/Diagnostics/Symbols.cs b/src/ARMeilleure/Diagnostics/Symbols.cs index 86469d8bb..bb2f5cef5 100644 --- a/src/ARMeilleure/Diagnostics/Symbols.cs +++ b/src/ARMeilleure/Diagnostics/Symbols.cs @@ -1,6 +1,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; +using System.Text; namespace ARMeilleure.Diagnostics { @@ -48,14 +49,15 @@ namespace ARMeilleure.Diagnostics ulong diff = address - symbol.Start; ulong rem = diff % symbol.ElementSize; - result = symbol.Name + "_" + diff / symbol.ElementSize; + StringBuilder resultBuilder = new(); + resultBuilder.Append($"{symbol.Name}_{diff / symbol.ElementSize}"); if (rem != 0) { - result += "+" + rem; + resultBuilder.Append($"+{rem}"); } - _symbols.TryAdd(address, result); + _symbols.TryAdd(address, resultBuilder.ToString()); return result; } diff --git a/src/Ryujinx.Ava/UI/ViewModels/AmiiboWindowViewModel.cs b/src/Ryujinx.Ava/UI/ViewModels/AmiiboWindowViewModel.cs index 3138dd146..83624f5f3 100644 --- a/src/Ryujinx.Ava/UI/ViewModels/AmiiboWindowViewModel.cs +++ b/src/Ryujinx.Ava/UI/ViewModels/AmiiboWindowViewModel.cs @@ -327,7 +327,7 @@ namespace Ryujinx.Ava.UI.ViewModels string imageUrl = _amiiboList.Find(amiibo => amiibo.Equals(selected)).Image; - string usageString = ""; + StringBuilder usageStringBuilder = new(); for (int i = 0; i < _amiiboList.Count; i++) { @@ -341,20 +341,19 @@ namespace Ryujinx.Ava.UI.ViewModels { foreach (AmiiboApiUsage usageItem in item.AmiiboUsage) { - usageString += Environment.NewLine + - $"- {usageItem.Usage.Replace("/", Environment.NewLine + "-")}"; + usageStringBuilder.Append($"{Environment.NewLine}- {usageItem.Usage.Replace("/", Environment.NewLine + "-")}"); writable = usageItem.Write; } } } - if (usageString.Length == 0) + if (usageStringBuilder.Length == 0) { - usageString = LocaleManager.Instance[LocaleKeys.Unknown] + "."; + usageStringBuilder.Append($"{LocaleManager.Instance[LocaleKeys.Unknown]}."); } - Usage = $"{LocaleManager.Instance[LocaleKeys.Usage]} {(writable ? $" ({LocaleManager.Instance[LocaleKeys.Writable]})" : "")} : {usageString}"; + Usage = $"{LocaleManager.Instance[LocaleKeys.Usage]} {(writable ? $" ({LocaleManager.Instance[LocaleKeys.Writable]})" : "")} : {usageStringBuilder}"; } } diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs index 7506f72af..cd9c71280 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/CodeGenContext.cs @@ -92,14 +92,14 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl private static string GetIndentation(int level) { - string indentation = string.Empty; + StringBuilder indentationBuilder = new(); for (int index = 0; index < level; index++) { - indentation += Tab; + indentationBuilder.Append(Tab); } - return indentation; + return indentationBuilder.ToString(); } } } diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs index 6b02f2bf4..eb0cb92db 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGen.cs @@ -2,6 +2,7 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation; using Ryujinx.Graphics.Shader.StructuredIr; using Ryujinx.Graphics.Shader.Translation; using System; +using System.Text; using static Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions.InstGenBallot; using static Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions.InstGenCall; @@ -67,11 +68,11 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions int arity = (int)(info.Type & InstType.ArityMask); - string args = string.Empty; + StringBuilder builder = new(); if (atomic && (operation.StorageKind == StorageKind.StorageBuffer || operation.StorageKind == StorageKind.SharedMemory)) { - args = GenerateLoadOrStore(context, operation, isStore: false); + builder.Append(GenerateLoadOrStore(context, operation, isStore: false)); AggregateType dstType = operation.Inst == Instruction.AtomicMaxS32 || operation.Inst == Instruction.AtomicMinS32 ? AggregateType.S32 @@ -79,7 +80,7 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions for (int argIndex = operation.SourcesCount - arity + 2; argIndex < operation.SourcesCount; argIndex++) { - args += ", " + GetSoureExpr(context, operation.GetSource(argIndex), dstType); + builder.Append($", {GetSoureExpr(context, operation.GetSource(argIndex), dstType)}"); } } else @@ -88,16 +89,16 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions { if (argIndex != 0) { - args += ", "; + builder.Append(", "); } AggregateType dstType = GetSrcVarType(inst, argIndex); - args += GetSoureExpr(context, operation.GetSource(argIndex), dstType); + builder.Append(GetSoureExpr(context, operation.GetSource(argIndex), dstType)); } } - return info.OpName + '(' + args + ')'; + return $"{info.OpName}({builder})"; } else if ((info.Type & InstType.Op) != 0) { diff --git a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs index 7510e8872..2e90bd16d 100644 --- a/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs +++ b/src/Ryujinx.Graphics.Shader/CodeGen/Glsl/Instructions/InstGenMemory.cs @@ -779,17 +779,18 @@ namespace Ryujinx.Graphics.Shader.CodeGen.Glsl.Instructions private static string GetMaskMultiDest(int mask) { - string swizzle = "."; + StringBuilder swizzleBuilder = new(); + swizzleBuilder.Append('.'); for (int i = 0; i < 4; i++) { if ((mask & (1 << i)) != 0) { - swizzle += "xyzw"[i]; + swizzleBuilder.Append("xyzw"[i]); } } - return swizzle; + return swizzleBuilder.ToString(); } } } diff --git a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs index e426d54de..8a730ef74 100644 --- a/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs +++ b/src/Ryujinx.Graphics.Shader/Translation/Optimizations/GlobalToStorage.cs @@ -2,6 +2,7 @@ using Ryujinx.Graphics.Shader.IntermediateRepresentation; using System; using System.Collections.Generic; using System.Linq; +using System.Text; using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper; namespace Ryujinx.Graphics.Shader.Translation.Optimizations @@ -785,30 +786,31 @@ namespace Ryujinx.Graphics.Shader.Translation.Optimizations private static string GetFunctionName(Operation baseOp, bool isMultiTarget, IReadOnlyList targetCbs) { - string name = baseOp.Inst.ToString(); + StringBuilder nameBuilder = new(); + nameBuilder.Append(baseOp.Inst.ToString()); - name += baseOp.StorageKind switch + nameBuilder.Append(baseOp.StorageKind switch { StorageKind.GlobalMemoryS8 => "S8", StorageKind.GlobalMemoryS16 => "S16", StorageKind.GlobalMemoryU8 => "U8", StorageKind.GlobalMemoryU16 => "U16", _ => string.Empty, - }; + }); if (isMultiTarget) { - name += "Multi"; + nameBuilder.Append("Multi"); } foreach (uint targetCb in targetCbs) { (int sbCbSlot, int sbCbOffset) = UnpackCbSlotAndOffset(targetCb); - name += $"_c{sbCbSlot}o{sbCbOffset}"; + nameBuilder.Append($"_c{sbCbSlot}o{sbCbOffset}"); } - return name; + return nameBuilder.ToString(); } private static bool TryGenerateStorageOp( diff --git a/src/Ryujinx.HLE/FileSystem/ContentManager.cs b/src/Ryujinx.HLE/FileSystem/ContentManager.cs index 13f987638..646808e78 100644 --- a/src/Ryujinx.HLE/FileSystem/ContentManager.cs +++ b/src/Ryujinx.HLE/FileSystem/ContentManager.cs @@ -19,6 +19,7 @@ using System.Collections.Generic; using System.IO; using System.IO.Compression; using System.Linq; +using System.Text; using Path = System.IO.Path; namespace Ryujinx.HLE.FileSystem @@ -817,13 +818,13 @@ namespace Ryujinx.HLE.FileSystem if (updateNcas.Count > 0) { - string extraNcas = string.Empty; + StringBuilder extraNcas = new(); foreach (var entry in updateNcas) { foreach (var (type, path) in entry.Value) { - extraNcas += path + Environment.NewLine; + extraNcas.AppendLine(path); } } @@ -954,13 +955,13 @@ namespace Ryujinx.HLE.FileSystem if (updateNcas.Count > 0) { - string extraNcas = string.Empty; + StringBuilder extraNcas = new(); foreach (var entry in updateNcas) { foreach (var (type, path) in entry.Value) { - extraNcas += path + Environment.NewLine; + extraNcas.AppendLine(path); } } diff --git a/src/Ryujinx.HLE/HOS/Kernel/Process/HleProcessDebugger.cs b/src/Ryujinx.HLE/HOS/Kernel/Process/HleProcessDebugger.cs index cbfef588c..7578f1d2f 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Process/HleProcessDebugger.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Process/HleProcessDebugger.cs @@ -436,14 +436,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Process uint nameIndex = sym.NameOffset; - string name = string.Empty; + StringBuilder nameBuilder = new(); for (int chr; (chr = memory.Read(strTblAddr + nameIndex++)) != 0;) { - name += (char)chr; + nameBuilder.Append((char)chr); } - return new ElfSymbol(name, sym.Info, sym.Other, sym.SectionIndex, sym.ValueAddress, sym.Size); + return new ElfSymbol(nameBuilder.ToString(), sym.Info, sym.Other, sym.SectionIndex, sym.ValueAddress, sym.Size); } private static ElfSymbol GetSymbol32(IVirtualMemoryManager memory, ulong address, ulong strTblAddr) @@ -452,14 +452,14 @@ namespace Ryujinx.HLE.HOS.Kernel.Process uint nameIndex = sym.NameOffset; - string name = string.Empty; + StringBuilder nameBuilder = new(); for (int chr; (chr = memory.Read(strTblAddr + nameIndex++)) != 0;) { - name += (char)chr; + nameBuilder.Append((char)chr); } - return new ElfSymbol(name, sym.Info, sym.Other, sym.SectionIndex, sym.ValueAddress, sym.Size); + return new ElfSymbol(nameBuilder.ToString(), sym.Info, sym.Other, sym.SectionIndex, sym.ValueAddress, sym.Size); } } } diff --git a/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs b/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs index 9110d06d3..3dc82035f 100644 --- a/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs +++ b/src/Ryujinx.HLE/HOS/Services/Sm/IUserInterface.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using System.Text; namespace Ryujinx.HLE.HOS.Services.Sm { @@ -235,7 +236,7 @@ namespace Ryujinx.HLE.HOS.Services.Sm private static string ReadName(ServiceCtx context) { - string name = string.Empty; + StringBuilder nameBuilder = new(); for (int index = 0; index < 8 && context.RequestData.BaseStream.Position < @@ -245,11 +246,11 @@ namespace Ryujinx.HLE.HOS.Services.Sm if (chr >= 0x20 && chr < 0x7f) { - name += (char)chr; + nameBuilder.Append((char)chr); } } - return name; + return nameBuilder.ToString(); } public override void DestroyAtExit() diff --git a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/IApplicationDisplayService.cs b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/IApplicationDisplayService.cs index 3fbd7d20d..143e21661 100644 --- a/src/Ryujinx.HLE/HOS/Services/Vi/RootService/IApplicationDisplayService.cs +++ b/src/Ryujinx.HLE/HOS/Services/Vi/RootService/IApplicationDisplayService.cs @@ -142,7 +142,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService // OpenDisplay(nn::vi::DisplayName) -> u64 display_id public ResultCode OpenDisplay(ServiceCtx context) { - string name = ""; + StringBuilder nameBuilder = new(); for (int index = 0; index < 8 && context.RequestData.BaseStream.Position < context.RequestData.BaseStream.Length; index++) { @@ -150,11 +150,11 @@ namespace Ryujinx.HLE.HOS.Services.Vi.RootService if (chr >= 0x20 && chr < 0x7f) { - name += (char)chr; + nameBuilder.Append((char)chr); } } - return OpenDisplayImpl(context, name); + return OpenDisplayImpl(context, nameBuilder.ToString()); } [CommandCmif(1011)] diff --git a/src/Ryujinx.Horizon/Sdk/Sm/ServiceName.cs b/src/Ryujinx.Horizon/Sdk/Sm/ServiceName.cs index c89f118cf..1233fad8a 100644 --- a/src/Ryujinx.Horizon/Sdk/Sm/ServiceName.cs +++ b/src/Ryujinx.Horizon/Sdk/Sm/ServiceName.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.InteropServices; +using System.Text; namespace Ryujinx.Horizon.Sdk.Sm { @@ -78,7 +79,7 @@ namespace Ryujinx.Horizon.Sdk.Sm public override string ToString() { - string name = string.Empty; + StringBuilder nameBuilder = new(); for (int index = 0; index < sizeof(ulong); index++) { @@ -89,10 +90,10 @@ namespace Ryujinx.Horizon.Sdk.Sm break; } - name += (char)character; + nameBuilder.Append((char)character); } - return name; + return nameBuilder.ToString(); } } } diff --git a/src/Ryujinx.Ui.LocaleGenerator/LocaleGenerator.cs b/src/Ryujinx.Ui.LocaleGenerator/LocaleGenerator.cs index 6fb19fae3..d1b9131d0 100644 --- a/src/Ryujinx.Ui.LocaleGenerator/LocaleGenerator.cs +++ b/src/Ryujinx.Ui.LocaleGenerator/LocaleGenerator.cs @@ -1,5 +1,6 @@ using Microsoft.CodeAnalysis; using System.Linq; +using System.Text; namespace Ryujinx.Ui.LocaleGenerator { @@ -15,15 +16,17 @@ namespace Ryujinx.Ui.LocaleGenerator context.RegisterSourceOutput(contents, (spc, content) => { var lines = content.Split('\n').Where(x => x.Trim().StartsWith("\"")).Select(x => x.Split(':')[0].Trim().Replace("\"", "")); - string enumSource = "namespace Ryujinx.Ava.Common.Locale;\n"; - enumSource += "internal enum LocaleKeys\n{\n"; + StringBuilder enumSourceBuilder = new(); + enumSourceBuilder.AppendLine("namespace Ryujinx.Ava.Common.Locale;"); + enumSourceBuilder.AppendLine("internal enum LocaleKeys"); + enumSourceBuilder.AppendLine("{"); foreach (var line in lines) { - enumSource += $" {line},\n"; + enumSourceBuilder.AppendLine($" {line},"); } - enumSource += "}\n"; + enumSourceBuilder.AppendLine("}"); - spc.AddSource("LocaleKeys", enumSource); + spc.AddSource("LocaleKeys", enumSourceBuilder.ToString()); }); } }