Browse Source

Removed redundant code from Block8x8F and Block8x8

pull/1853/head
Dmitry Pentin 5 years ago
parent
commit
140b07854e
  1. 6
      src/ImageSharp/Formats/Jpeg/Components/Block8x8.Intrinsic.cs
  2. 22
      src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs
  3. 7
      src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs
  4. 14
      tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs

6
src/ImageSharp/Formats/Jpeg/Components/Block8x8.Intrinsic.cs

@ -2,16 +2,12 @@
// Licensed under the Apache License, Version 2.0.
#if SUPPORTS_RUNTIME_INTRINSICS
using System;
using System.Runtime.InteropServices;
#if SUPPORTS_RUNTIME_INTRINSICS
using System.Runtime.Intrinsics;
#endif
namespace SixLabors.ImageSharp.Formats.Jpeg.Components
{
internal unsafe partial struct Block8x8 : IEquatable<Block8x8>
internal unsafe partial struct Block8x8
{
[FieldOffset(0)]
public Vector128<short> V0;

22
src/ImageSharp/Formats/Jpeg/Components/Block8x8.cs

@ -18,7 +18,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
/// </summary>
// ReSharper disable once InconsistentNaming
[StructLayout(LayoutKind.Explicit)]
internal unsafe partial struct Block8x8 : IEquatable<Block8x8>
internal unsafe partial struct Block8x8
{
/// <summary>
/// A number of scalar coefficients in a <see cref="Block8x8F"/>
@ -164,26 +164,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
return sb.ToString();
}
/// <inheritdoc />
public bool Equals(Block8x8 other)
{
for (int i = 0; i < Size; i++)
{
if (this[i] != other[i])
{
return false;
}
}
return true;
}
/// <inheritdoc />
public override bool Equals(object obj) => obj is Block8x8 other && this.Equals(other);
/// <inheritdoc />
public override int GetHashCode() => (this[0] * 31) + this[1];
/// <summary>
/// Returns index of the last non-zero element in given matrix.
/// </summary>

7
src/ImageSharp/Formats/Jpeg/Components/Block8x8F.cs

@ -104,13 +104,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Components
return result;
}
public static Block8x8F Load(Span<int> data)
{
Block8x8F result = default;
result.LoadFrom(data);
return result;
}
/// <summary>
/// Load raw 32bit floating point data from source.
/// </summary>

14
tests/ImageSharp.Tests/Formats/Jpg/Block8x8Tests.cs

@ -70,20 +70,6 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg
Assert.Equal(data, result);
}
[Fact]
public void Equality_WhenTrue()
{
short[] data = Create8x8ShortData();
var block1 = Block8x8.Load(data);
var block2 = Block8x8.Load(data);
block1[0] = 42;
block2[0] = 42;
Assert.Equal(block1, block2);
Assert.Equal(block1.GetHashCode(), block2.GetHashCode());
}
[Fact]
public void Equality_WhenFalse()
{

Loading…
Cancel
Save