diff --git a/src/SixLabors.Core/Helpers/HashHelpers.cs b/src/SixLabors.Core/Helpers/HashHelpers.cs
index 40a2b3f96a..a453a53de5 100644
--- a/src/SixLabors.Core/Helpers/HashHelpers.cs
+++ b/src/SixLabors.Core/Helpers/HashHelpers.cs
@@ -13,7 +13,7 @@ namespace SixLabors
///
/// Hash code one
/// Hash code two
- /// Returns a hash code for the two specified has codes.
+ /// Returns a hash code for the provided hash codes.
public static int Combine(int h1, int h2)
{
unchecked
@@ -24,5 +24,39 @@ namespace SixLabors
return ((int)rol5 + h1) ^ h2;
}
}
+
+ ///
+ /// Combines the three specified hash codes.
+ ///
+ /// The first
+ /// Hash code two
+ /// Hash code three
+ /// Returns a hash code for the provided hash codes.
+ public static int Combine(int h1, int h2, int h3)
+ {
+ int hash = Combine(h1, h2);
+
+ hash = Combine(hash, h3);
+
+ return hash;
+ }
+
+ ///
+ /// Combines the four specified hash codes.
+ ///
+ /// The first
+ /// Hash code two
+ /// Hash code three
+ /// Hash code four
+ /// Returns a hash code for the provided hash codes.
+ public static int Combine(int h1, int h2, int h3, int h4)
+ {
+ int hash = Combine(h1, h2);
+
+ hash = Combine(hash, h3);
+ hash = Combine(hash, h4);
+
+ return hash;
+ }
}
}
diff --git a/src/SixLabors.Core/Primitives/Rectangle.cs b/src/SixLabors.Core/Primitives/Rectangle.cs
index 27cba5d15e..b68732c40c 100644
--- a/src/SixLabors.Core/Primitives/Rectangle.cs
+++ b/src/SixLabors.Core/Primitives/Rectangle.cs
@@ -460,11 +460,12 @@ namespace SixLabors.Primitives
private int GetHashCode(Rectangle rectangle)
{
- int hashCode = rectangle.X.GetHashCode();
- hashCode = HashHelpers.Combine(hashCode, rectangle.Y.GetHashCode());
- hashCode = HashHelpers.Combine(hashCode, rectangle.Width.GetHashCode());
- hashCode = HashHelpers.Combine(hashCode, rectangle.Height.GetHashCode());
- return hashCode;
+ return HashHelpers.Combine(
+ rectangle.X.GetHashCode(),
+ rectangle.Y.GetHashCode(),
+ rectangle.Width.GetHashCode(),
+ rectangle.Height.GetHashCode()
+ );
}
}
}
\ No newline at end of file
diff --git a/src/SixLabors.Core/Primitives/RectangleF.cs b/src/SixLabors.Core/Primitives/RectangleF.cs
index d5ee6a61b4..a33d227e06 100644
--- a/src/SixLabors.Core/Primitives/RectangleF.cs
+++ b/src/SixLabors.Core/Primitives/RectangleF.cs
@@ -393,11 +393,12 @@ namespace SixLabors.Primitives
private int GetHashCode(RectangleF rectangle)
{
- int hashCode = rectangle.X.GetHashCode();
- hashCode = HashHelpers.Combine(hashCode, rectangle.Y.GetHashCode());
- hashCode = HashHelpers.Combine(hashCode, rectangle.Width.GetHashCode());
- hashCode = HashHelpers.Combine(hashCode, rectangle.Height.GetHashCode());
- return hashCode;
+ return HashHelpers.Combine(
+ rectangle.X.GetHashCode(),
+ rectangle.Y.GetHashCode(),
+ rectangle.Width.GetHashCode(),
+ rectangle.Height.GetHashCode()
+ );
}
}
}
\ No newline at end of file