From 9f9fa1c6ebaf2f9c0bed7aa8ee35d3774d46bb77 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Thu, 6 Dec 2018 08:50:28 -0800 Subject: [PATCH] Remove indirection getting HashCode on ExifValue --- .../MetaData/Profiles/Exif/ExifValue.cs | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs index ccacfd0bf..c5332788f 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifValue.cs @@ -198,7 +198,14 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif } /// - public override int GetHashCode() => this.GetHashCode(this); + public override int GetHashCode() + { + int hashCode = HashHelpers.Combine(this.Tag.GetHashCode(), this.DataType.GetHashCode()); + + return this.Value != null + ? HashHelpers.Combine(hashCode, this.Value.GetHashCode()) + : hashCode; + } /// public override string ToString() @@ -714,20 +721,5 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif throw new NotSupportedException(); } } - - /// - /// Returns the hash code for this instance. - /// - /// - /// The instance of to return the hash code for. - /// - /// - /// A 32-bit signed integer that is the hash code for this instance. - /// - private int GetHashCode(ExifValue exif) - { - int hashCode = exif.Tag.GetHashCode() ^ exif.DataType.GetHashCode(); - return hashCode ^ exif.Value?.GetHashCode() ?? hashCode; - } } } \ No newline at end of file