Browse Source

Optimize remaining equality checks using pattern matching

pull/639/head
Jason Nelson 8 years ago
parent
commit
5ae24b0817
  1. 7
      src/ImageSharp/ColorSpaces/CieLab.cs
  2. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs
  3. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs
  4. 12
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs
  5. 2
      src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs
  6. 2
      src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs
  7. 2
      src/ImageSharp/PixelFormats/Bgr565.cs
  8. 2
      src/ImageSharp/PixelFormats/HalfSingle.cs
  9. 2
      src/ImageSharp/PixelFormats/HalfVector2.cs
  10. 2
      src/ImageSharp/PixelFormats/NormalizedShort2.cs
  11. 2
      src/ImageSharp/PixelFormats/Rg32.cs
  12. 3
      tests/ImageSharp.Tests/Memory/BufferTestSuite.cs

7
src/ImageSharp/ColorSpaces/CieLab.cs

@ -194,12 +194,7 @@ namespace SixLabors.ImageSharp.ColorSpaces
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override bool Equals(object obj)
{
if (obj is CieLab)
{
return this.Equals((CieLab)obj);
}
return false;
return obj is CieLab other && this.Equals(other);
}
/// <inheritdoc/>

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccChromaticityTagDataEntry.cs

@ -104,7 +104,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
public override bool Equals(object obj)
{
return obj is IccChromaticityTagDataEntry && this.Equals((IccChromaticityTagDataEntry)obj);
return obj is IccChromaticityTagDataEntry other && this.Equals(other);
}
/// <inheritdoc/>

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccDateTimeTagDataEntry.cs

@ -60,7 +60,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
public override bool Equals(object obj)
{
return obj is IccDateTimeTagDataEntry && this.Equals((IccDateTimeTagDataEntry)obj);
return obj is IccDateTimeTagDataEntry other && this.Equals(other);
}
/// <inheritdoc/>

12
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccResponseCurveSet16TagDataEntry.cs

@ -77,17 +77,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc />
public override bool Equals(object obj)
{
if (obj is null)
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj is IccResponseCurveSet16TagDataEntry && this.Equals((IccResponseCurveSet16TagDataEntry)obj);
return obj is IccResponseCurveSet16TagDataEntry other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccViewingConditionsTagDataEntry.cs

@ -80,7 +80,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
public override bool Equals(object obj)
{
return obj is IccViewingConditionsTagDataEntry && this.Equals((IccViewingConditionsTagDataEntry)obj);
return obj is IccViewingConditionsTagDataEntry other && this.Equals(other);
}
/// <inheritdoc/>

2
src/ImageSharp/MetaData/Profiles/ICC/Various/IccScreeningChannel.cs

@ -77,7 +77,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Icc
/// <inheritdoc/>
public override bool Equals(object obj)
{
return obj is IccScreeningChannel && this.Equals((IccScreeningChannel)obj);
return obj is IccScreeningChannel other && this.Equals(other);
}
/// <inheritdoc/>

2
src/ImageSharp/PixelFormats/Bgr565.cs

@ -206,7 +206,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is Bgr565) && this.Equals((Bgr565)obj);
return obj is Bgr565 other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/PixelFormats/HalfSingle.cs

@ -211,7 +211,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is HalfSingle) && this.Equals((HalfSingle)obj);
return obj is HalfSingle other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/PixelFormats/HalfVector2.cs

@ -239,7 +239,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is HalfVector2) && this.Equals((HalfVector2)obj);
return obj is HalfVector2 other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/PixelFormats/NormalizedShort2.cs

@ -247,7 +247,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is NormalizedShort2) && this.Equals((NormalizedShort2)obj);
return obj is NormalizedShort2 other && this.Equals(other);
}
/// <inheritdoc />

2
src/ImageSharp/PixelFormats/Rg32.cs

@ -210,7 +210,7 @@ namespace SixLabors.ImageSharp.PixelFormats
/// <inheritdoc />
public override bool Equals(object obj)
{
return (obj is Rg32) && this.Equals((Rg32)obj);
return obj is Rg32 other && this.Equals(other);
}
/// <inheritdoc />

3
tests/ImageSharp.Tests/Memory/BufferTestSuite.cs

@ -46,8 +46,7 @@ namespace SixLabors.ImageSharp.Tests.Memory
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is CustomStruct && this.Equals((CustomStruct)obj);
return obj is CustomStruct other && this.Equals(other);
}
public override int GetHashCode()

Loading…
Cancel
Save