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 --- ARMeilleure/CodeGen/RegisterAllocators/AllocationResult.cs | 2 +- ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs | 2 +- ARMeilleure/CodeGen/RegisterAllocators/HybridAllocator.cs | 2 +- ARMeilleure/CodeGen/RegisterAllocators/RegisterMasks.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'ARMeilleure/CodeGen/RegisterAllocators') diff --git a/ARMeilleure/CodeGen/RegisterAllocators/AllocationResult.cs b/ARMeilleure/CodeGen/RegisterAllocators/AllocationResult.cs index 94ac6991..43e5c7e2 100644 --- a/ARMeilleure/CodeGen/RegisterAllocators/AllocationResult.cs +++ b/ARMeilleure/CodeGen/RegisterAllocators/AllocationResult.cs @@ -1,6 +1,6 @@ namespace ARMeilleure.CodeGen.RegisterAllocators { - struct AllocationResult + readonly struct AllocationResult { public int IntUsedRegisters { get; } public int VecUsedRegisters { get; } diff --git a/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs b/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs index df4b6db1..587b1a02 100644 --- a/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs +++ b/ARMeilleure/CodeGen/RegisterAllocators/CopyResolver.cs @@ -11,7 +11,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators { private class ParallelCopy { - private struct Copy + private readonly struct Copy { public Register Dest { get; } public Register Source { get; } diff --git a/ARMeilleure/CodeGen/RegisterAllocators/HybridAllocator.cs b/ARMeilleure/CodeGen/RegisterAllocators/HybridAllocator.cs index de084026..25952c77 100644 --- a/ARMeilleure/CodeGen/RegisterAllocators/HybridAllocator.cs +++ b/ARMeilleure/CodeGen/RegisterAllocators/HybridAllocator.cs @@ -11,7 +11,7 @@ namespace ARMeilleure.CodeGen.RegisterAllocators { class HybridAllocator : IRegisterAllocator { - private struct BlockInfo + private readonly struct BlockInfo { public bool HasCall { get; } diff --git a/ARMeilleure/CodeGen/RegisterAllocators/RegisterMasks.cs b/ARMeilleure/CodeGen/RegisterAllocators/RegisterMasks.cs index 9652224e..5b11aac2 100644 --- a/ARMeilleure/CodeGen/RegisterAllocators/RegisterMasks.cs +++ b/ARMeilleure/CodeGen/RegisterAllocators/RegisterMasks.cs @@ -3,7 +3,7 @@ using System; namespace ARMeilleure.CodeGen.RegisterAllocators { - struct RegisterMasks + readonly struct RegisterMasks { public int IntAvailableRegisters { get; } public int VecAvailableRegisters { get; } -- cgit v1.2.3