From 14032a5b1c78cf7cb478b621ab24cfb9c51c7023 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sat, 26 Jul 2025 12:09:16 +1000 Subject: [PATCH] Convert `Bit` to a `readonly record struct` --- src/BizHawk.Common/Bit.cs | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/BizHawk.Common/Bit.cs b/src/BizHawk.Common/Bit.cs index fa7188ca53..7b911596c3 100644 --- a/src/BizHawk.Common/Bit.cs +++ b/src/BizHawk.Common/Bit.cs @@ -3,15 +3,8 @@ using System.Diagnostics; namespace BizHawk.Common { // I think this is a little faster with uint than with byte - public readonly struct Bit + public readonly record struct Bit(uint _val) { - private readonly uint _val; - - public Bit(uint val) - { - _val = val; - } - public static implicit operator Bit(int rhs) { Debug.Assert((rhs & ~1) is 0, "higher bits can't be used"); @@ -37,25 +30,5 @@ namespace BizHawk.Common { return _val.ToString(); } - - public static bool operator ==(Bit lhs, Bit rhs) - { - return lhs._val == rhs._val; - } - - public static bool operator !=(Bit lhs, Bit rhs) - { - return lhs._val != rhs._val; - } - - public override int GetHashCode() - { - return _val.GetHashCode(); - } - - public override bool Equals(object? obj) - { - return obj is Bit b && this == b; - } } }