From 4da44e09cb2a32f69b4a6b47221117b78e4618dc Mon Sep 17 00:00:00 2001 From: Andrey Sukharev Date: Mon, 5 Dec 2022 16:47:39 +0300 Subject: Make structs readonly when applicable (#4002) * Make all structs readonly when applicable. It should reduce amount of needless defensive copies * Make structs with trivial boilerplate equality code record structs * Remove unnecessary readonly modifiers from TextureCreateInfo * Make BitMap structs readonly too --- Ryujinx.Graphics.Shader/Decoders/Block.cs | 2 +- Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs | 2 +- Ryujinx.Graphics.Shader/Decoders/Decoder.cs | 2 +- Ryujinx.Graphics.Shader/Decoders/InstTable.cs | 2 +- Ryujinx.Graphics.Shader/Decoders/Register.cs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'Ryujinx.Graphics.Shader/Decoders') diff --git a/Ryujinx.Graphics.Shader/Decoders/Block.cs b/Ryujinx.Graphics.Shader/Decoders/Block.cs index ddd81cc5..7d94e3f9 100644 --- a/Ryujinx.Graphics.Shader/Decoders/Block.cs +++ b/Ryujinx.Graphics.Shader/Decoders/Block.cs @@ -17,7 +17,7 @@ namespace Ryujinx.Graphics.Shader.Decoders } } - struct SyncTarget + readonly struct SyncTarget { public PushOpInfo PushOpInfo { get; } public int PushOpId { get; } diff --git a/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs b/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs index 80de41d7..2dd60155 100644 --- a/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs +++ b/Ryujinx.Graphics.Shader/Decoders/DecodedProgram.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; namespace Ryujinx.Graphics.Shader.Decoders { - struct DecodedProgram : IEnumerable + readonly struct DecodedProgram : IEnumerable { public DecodedFunction MainFunction { get; } private readonly IReadOnlyDictionary _functions; diff --git a/Ryujinx.Graphics.Shader/Decoders/Decoder.cs b/Ryujinx.Graphics.Shader/Decoders/Decoder.cs index 9dafb089..380c425e 100644 --- a/Ryujinx.Graphics.Shader/Decoders/Decoder.cs +++ b/Ryujinx.Graphics.Shader/Decoders/Decoder.cs @@ -473,7 +473,7 @@ namespace Ryujinx.Graphics.Shader.Decoders op = Unsafe.As(ref rawOp); } - private struct BlockLocation + private readonly struct BlockLocation { public Block Block { get; } public int Index { get; } diff --git a/Ryujinx.Graphics.Shader/Decoders/InstTable.cs b/Ryujinx.Graphics.Shader/Decoders/InstTable.cs index 0a64632e..911f1581 100644 --- a/Ryujinx.Graphics.Shader/Decoders/InstTable.cs +++ b/Ryujinx.Graphics.Shader/Decoders/InstTable.cs @@ -6,7 +6,7 @@ namespace Ryujinx.Graphics.Shader.Decoders { private const int EncodingBits = 14; - private struct TableEntry + private readonly struct TableEntry { public InstName Name { get; } public InstEmitter Emitter { get; } diff --git a/Ryujinx.Graphics.Shader/Decoders/Register.cs b/Ryujinx.Graphics.Shader/Decoders/Register.cs index 30840d8c..e375096d 100644 --- a/Ryujinx.Graphics.Shader/Decoders/Register.cs +++ b/Ryujinx.Graphics.Shader/Decoders/Register.cs @@ -2,7 +2,7 @@ using System; namespace Ryujinx.Graphics.Shader.Decoders { - struct Register : IEquatable + readonly struct Register : IEquatable { public int Index { get; } -- cgit v1.2.3