From ec71282ce31b975d30b9cc950be44dae34d550d7 Mon Sep 17 00:00:00 2001 From: Travis Nickles Date: Wed, 16 Jan 2019 05:07:19 -0600 Subject: [PATCH] Changed DS4Color to use IEquatable interface Allows for faster Equals method than the previous implementation --- DS4Windows/DS4Library/DS4Device.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/DS4Windows/DS4Library/DS4Device.cs b/DS4Windows/DS4Library/DS4Device.cs index 952bf53..9dd72ec 100644 --- a/DS4Windows/DS4Library/DS4Device.cs +++ b/DS4Windows/DS4Library/DS4Device.cs @@ -12,7 +12,7 @@ using DS4Windows.DS4Library; namespace DS4Windows { - public struct DS4Color + public struct DS4Color : IEquatable { public byte red; public byte green; @@ -31,15 +31,9 @@ namespace DS4Windows blue = b; } - public override bool Equals(object obj) + public bool Equals(DS4Color other) { - if (obj is DS4Color) - { - DS4Color dsc = ((DS4Color)obj); - return (this.red == dsc.red && this.green == dsc.green && this.blue == dsc.blue); - } - else - return false; + return this.red == other.red && this.green == other.green && this.blue == other.blue; } public Color ToColor => Color.FromArgb(red, green, blue);