Convert `Bit` to a `readonly record struct`

This commit is contained in:
YoshiRulz 2025-07-26 12:09:16 +10:00
parent f458acbbb4
commit 14032a5b1c
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 1 additions and 28 deletions

View File

@ -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;
}
}
}