Browse Source

Seal classes and avoid calling SuppressFinalize

pull/1846/head
Brian Popow 5 years ago
parent
commit
14508498d9
  1. 24
      src/ImageSharp/Formats/Webp/Lossless/CostManager.cs
  2. 2
      src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs
  3. 23
      src/ImageSharp/Formats/Webp/Lossless/Vp8LHashChain.cs

24
src/ImageSharp/Formats/Webp/Lossless/CostManager.cs

@ -13,10 +13,8 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless
/// It caches the different CostCacheInterval, caches the different
/// GetLengthCost(costModel, k) in costCache and the CostInterval's.
/// </summary>
internal class CostManager : IDisposable
internal sealed class CostManager : IDisposable
{
private bool disposed;
private CostInterval head;
private const int FreeIntervalsStartCount = 25;
@ -328,25 +326,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless
}
}
protected virtual void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
this.Costs.Dispose();
}
this.disposed = true;
}
}
/// <inheritdoc />
public void Dispose()
{
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
this.Dispose(disposing: true);
GC.SuppressFinalize(this);
}
public void Dispose() => this.Costs.Dispose();
}
}

2
src/ImageSharp/Formats/Webp/Lossless/PixOrCopy.cs

@ -6,7 +6,7 @@ using System.Diagnostics;
namespace SixLabors.ImageSharp.Formats.Webp.Lossless
{
[DebuggerDisplay("Mode: {Mode}, Len: {Len}, BgraOrDistance: {BgraOrDistance}")]
internal class PixOrCopy
internal sealed class PixOrCopy
{
public PixOrCopyMode Mode { get; set; }

23
src/ImageSharp/Formats/Webp/Lossless/Vp8LHashChain.cs

@ -8,7 +8,7 @@ using SixLabors.ImageSharp.Memory;
namespace SixLabors.ImageSharp.Formats.Webp.Lossless
{
internal class Vp8LHashChain : IDisposable
internal sealed class Vp8LHashChain : IDisposable
{
private const uint HashMultiplierHi = 0xc6a4a793u;
@ -30,8 +30,6 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless
private readonly MemoryAllocator memoryAllocator;
private bool disposed;
/// <summary>
/// Initializes a new instance of the <see cref="Vp8LHashChain"/> class.
/// </summary>
@ -288,24 +286,7 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless
return maxWindowSize > WindowSize ? WindowSize : maxWindowSize;
}
protected virtual void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
this.OffsetLength.Dispose();
}
this.disposed = true;
}
}
/// <inheritdoc />
public void Dispose()
{
this.Dispose(disposing: true);
GC.SuppressFinalize(this);
}
public void Dispose() => this.OffsetLength.Dispose();
}
}

Loading…
Cancel
Save