Browse Source

Update (hashCode * 397) pattern to use HashHelpers

af/merge-core
Jason Nelson 7 years ago
parent
commit
2fa5e3135e
  1. 2
      src/ImageSharp/MetaData/ImageProperty.cs
  2. 14
      src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs
  3. 8
      src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs
  4. 10
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs
  5. 15
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs
  6. 15
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs
  7. 23
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
  8. 19
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
  9. 17
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs
  10. 18
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs
  11. 17
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs
  12. 15
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs
  13. 17
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs

2
src/ImageSharp/MetaData/ImageProperty.cs

@ -106,7 +106,7 @@ namespace SixLabors.ImageSharp.MetaData
int hashCode = this.Name.GetHashCode();
if (this.Value != null)
{
hashCode = (hashCode * 397) ^ this.Value.GetHashCode();
hashCode = HashHelpers.Combine(hashCode, this.Value.GetHashCode());
}
return hashCode;

14
src/ImageSharp/MetaData/Profiles/ICC/Curves/IccParametricCurve.cs

@ -157,13 +157,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
unchecked
{
int hashCode = (int)this.Type;
hashCode = (hashCode * 397) ^ this.G.GetHashCode();
hashCode = (hashCode * 397) ^ this.A.GetHashCode();
hashCode = (hashCode * 397) ^ this.B.GetHashCode();
hashCode = (hashCode * 397) ^ this.C.GetHashCode();
hashCode = (hashCode * 397) ^ this.D.GetHashCode();
hashCode = (hashCode * 397) ^ this.E.GetHashCode();
hashCode = (hashCode * 397) ^ this.F.GetHashCode();
hashCode = HashHelpers.Combine(hashCode, this.G.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.A.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.B.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.C.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.D.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.E.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.F.GetHashCode());
return hashCode;
}
}

8
src/ImageSharp/MetaData/Profiles/ICC/IccTagDataEntry.cs

@ -64,12 +64,6 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
}
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
return (int)this.Signature * 397;
}
}
public override int GetHashCode() => this.Signature.GetHashCode();
}
}

10
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccCrdInfoTagDataEntry.cs

@ -124,11 +124,11 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (this.PostScriptProductName?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.RenderingIntent0Crd?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.RenderingIntent1Crd?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.RenderingIntent2Crd?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.RenderingIntent3Crd?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.PostScriptProductName?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.RenderingIntent0Crd?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.RenderingIntent1Crd?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.RenderingIntent2Crd?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.RenderingIntent3Crd?.GetHashCode() ?? 0);
return hashCode;
}
}

15
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut16TagDataEntry.cs

@ -140,15 +140,12 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode();
hashCode = (hashCode * 397) ^ this.InputValues.GetHashCode();
hashCode = (hashCode * 397) ^ this.ClutValues.GetHashCode();
hashCode = (hashCode * 397) ^ this.OutputValues.GetHashCode();
return hashCode;
}
int hashCode = base.GetHashCode();
hashCode = HashHelpers.Combine(hashCode, this.Matrix.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.InputValues.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.ClutValues.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.OutputValues.GetHashCode());
return hashCode;
}
private Matrix4x4 CreateMatrix(float[,] matrix)

15
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLut8TagDataEntry.cs

@ -143,15 +143,12 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix.GetHashCode();
hashCode = (hashCode * 397) ^ this.InputValues.GetHashCode();
hashCode = (hashCode * 397) ^ this.ClutValues.GetHashCode();
hashCode = (hashCode * 397) ^ this.OutputValues.GetHashCode();
return hashCode;
}
int hashCode = base.GetHashCode();
hashCode = HashHelpers.Combine(hashCode, this.Matrix.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.InputValues.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.ClutValues.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.OutputValues.GetHashCode());
return hashCode;
}
private Matrix4x4 CreateMatrix(float[,] matrix)

23
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs

@ -183,19 +183,16 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.InputChannelCount;
hashCode = (hashCode * 397) ^ this.OutputChannelCount;
hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode();
hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.CurveB?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.CurveM?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.CurveA?.GetHashCode() ?? 0);
return hashCode;
}
int hashCode = base.GetHashCode();
hashCode = HashHelpers.Combine(hashCode, this.InputChannelCount.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.OutputChannelCount.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.Matrix3x3.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.Matrix3x1.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.ClutValues?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.CurveB?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.CurveM?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.CurveA?.GetHashCode() ?? 0);
return hashCode;
}
private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves)

19
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs

@ -183,19 +183,16 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.InputChannelCount;
hashCode = (hashCode * 397) ^ this.OutputChannelCount;
hashCode = (hashCode * 397) ^ this.Matrix3x3.GetHashCode();
hashCode = (hashCode * 397) ^ this.Matrix3x1.GetHashCode();
hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.CurveB?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.CurveM?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.CurveA?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.InputChannelCount.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.OutputChannelCount.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.Matrix3x3.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.Matrix3x1.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.ClutValues?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.CurveB?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.CurveM?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.CurveA?.GetHashCode() ?? 0);
return hashCode;
}
}
private bool EqualsCurve(IccTagDataEntry[] thisCurves, IccTagDataEntry[] entryCurves)

17
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccMeasurementTagDataEntry.cs

@ -106,16 +106,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.Observer;
hashCode = (hashCode * 397) ^ this.XyzBacking.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.Geometry;
hashCode = (hashCode * 397) ^ this.Flare.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.Illuminant;
return hashCode;
}
int hashCode = base.GetHashCode();
hashCode = HashHelpers.Combine(hashCode, this.Observer.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.XyzBacking.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.Geometry.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.Flare.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.Illuminant.GetHashCode());
return hashCode;
}
}
}

18
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccNamedColor2TagDataEntry.cs

@ -83,6 +83,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
if (colors.Length > 0)
{
coordinateCount = colors[0].DeviceCoordinates?.Length ?? 0;
Guard.IsFalse(colors.Any(t => (t.DeviceCoordinates?.Length ?? 0) != coordinateCount), nameof(colors), "Device coordinate count must be the same for all colors");
}
@ -154,16 +155,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ this.CoordinateCount;
hashCode = (hashCode * 397) ^ (this.Prefix?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.Suffix?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ this.VendorFlags;
hashCode = (hashCode * 397) ^ (this.Colors?.GetHashCode() ?? 0);
return hashCode;
}
int hashCode = base.GetHashCode();
hashCode = HashHelpers.Combine(hashCode, this.CoordinateCount.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.Prefix?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.Suffix?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.VendorFlags.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.Colors.GetHashCode());
return hashCode;
}
}
}

17
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccTextDescriptionTagDataEntry.cs

@ -166,16 +166,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
int hashCode = base.GetHashCode();
hashCode = (hashCode * 397) ^ (this.Ascii?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.Unicode?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (this.ScriptCode?.GetHashCode() ?? 0);
hashCode = (hashCode * 397) ^ (int)this.UnicodeLanguageCode;
hashCode = (hashCode * 397) ^ this.ScriptCodeCode.GetHashCode();
return hashCode;
}
int hashCode = base.GetHashCode();
hashCode = HashHelpers.Combine(hashCode, this.Ascii?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.Unicode?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.ScriptCode?.GetHashCode() ?? 0);
hashCode = HashHelpers.Combine(hashCode, this.UnicodeLanguageCode.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.ScriptCodeCode.GetHashCode());
return hashCode;
}
}
}

15
src/ImageSharp/MetaData/Profiles/ICC/Various/IccClut.cs

@ -142,15 +142,12 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
public override int GetHashCode()
{
unchecked
{
int hashCode = this.Values.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.DataType;
hashCode = (hashCode * 397) ^ this.InputChannelCount;
hashCode = (hashCode * 397) ^ this.OutputChannelCount;
hashCode = (hashCode * 397) ^ this.GridPointCount.GetHashCode();
return hashCode;
}
int hashCode = this.Values.GetHashCode();
hashCode = HashHelpers.Combine(hashCode, this.DataType.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.InputChannelCount.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.OutputChannelCount.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.GridPointCount.GetHashCode());
return hashCode;
}
private bool EqualsValuesArray(IccClut other)

17
src/ImageSharp/MetaData/Profiles/ICC/Various/IccProfileDescription.cs

@ -84,16 +84,13 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc />
public override int GetHashCode()
{
unchecked
{
int hashCode = (int)this.DeviceManufacturer;
hashCode = (hashCode * 397) ^ (int)this.DeviceModel;
hashCode = (hashCode * 397) ^ this.DeviceAttributes.GetHashCode();
hashCode = (hashCode * 397) ^ (int)this.TechnologyInformation;
hashCode = (hashCode * 397) ^ this.DeviceManufacturerInfo.GetHashCode();
hashCode = (hashCode * 397) ^ this.DeviceModelInfo.GetHashCode();
return hashCode;
}
int hashCode = this.DeviceManufacturer.GetHashCode();
hashCode = HashHelpers.Combine(hashCode, this.DeviceModel.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.DeviceAttributes.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.TechnologyInformation.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.DeviceManufacturerInfo.GetHashCode());
hashCode = HashHelpers.Combine(hashCode, this.DeviceModelInfo.GetHashCode());
return hashCode;
}
}
}

Loading…
Cancel
Save