Changed DS4Color to use IEquatable interface

Allows for faster Equals method than the previous
implementation
This commit is contained in:
Travis Nickles 2019-01-16 05:07:19 -06:00
parent df1ec44f1c
commit ec71282ce3

View File

@ -12,7 +12,7 @@ using DS4Windows.DS4Library;
namespace DS4Windows namespace DS4Windows
{ {
public struct DS4Color public struct DS4Color : IEquatable<DS4Color>
{ {
public byte red; public byte red;
public byte green; public byte green;
@ -31,15 +31,9 @@ namespace DS4Windows
blue = b; blue = b;
} }
public override bool Equals(object obj) public bool Equals(DS4Color other)
{ {
if (obj is DS4Color) return this.red == other.red && this.green == other.green && this.blue == other.blue;
{
DS4Color dsc = ((DS4Color)obj);
return (this.red == dsc.red && this.green == dsc.green && this.blue == dsc.blue);
}
else
return false;
} }
public Color ToColor => Color.FromArgb(red, green, blue); public Color ToColor => Color.FromArgb(red, green, blue);