Browse Source

use ImageSharp Guard / DebugGuard

af/merge-core
Anton Firszov 8 years ago
parent
commit
6efeafb663
  1. 2
      src/ImageSharp/Memory/ArrayPoolMemoryAllocator.cs
  2. 2
      src/ImageSharp/Memory/BasicArrayBuffer.cs
  3. 2
      src/ImageSharp/Memory/Buffer2D{T}.cs
  4. 2
      src/ImageSharp/Memory/BufferArea{T}.cs

2
src/ImageSharp/Memory/ArrayPoolMemoryAllocator.cs

@ -62,7 +62,7 @@ namespace SixLabors.Memory
public ArrayPoolMemoryAllocator(int maxPoolSizeInBytes, int poolSelectorThresholdInBytes, int maxArraysPerBucketLargePool, int maxArraysPerBucketNormalPool)
{
ImageSharp.Guard.MustBeGreaterThan(maxPoolSizeInBytes, 0, nameof(maxPoolSizeInBytes));
Guard.MustBeLessThanOrEqualTo(poolSelectorThresholdInBytes, maxPoolSizeInBytes, nameof(poolSelectorThresholdInBytes));
ImageSharp.Guard.MustBeLessThanOrEqualTo(poolSelectorThresholdInBytes, maxPoolSizeInBytes, nameof(poolSelectorThresholdInBytes));
this.MaxPoolSizeInBytes = maxPoolSizeInBytes;
this.PoolSelectorThresholdInBytes = poolSelectorThresholdInBytes;

2
src/ImageSharp/Memory/BasicArrayBuffer.cs

@ -38,7 +38,7 @@ namespace SixLabors.Memory
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
DebugGuard.MustBeLessThan(index, this.Length, nameof(index));
ImageSharp.DebugGuard.MustBeLessThan(index, this.Length, nameof(index));
Span<T> span = this.GetSpan();
return ref span[index];

2
src/ImageSharp/Memory/Buffer2D{T}.cs

@ -62,7 +62,7 @@ namespace SixLabors.Memory
get
{
ImageSharp.DebugGuard.MustBeLessThan(x, this.Width, nameof(x));
DebugGuard.MustBeLessThan(y, this.Height, nameof(y));
ImageSharp.DebugGuard.MustBeLessThan(y, this.Height, nameof(y));
Span<T> span = this.Span;
return ref span[(this.Width * y) + x];
}

2
src/ImageSharp/Memory/BufferArea{T}.cs

@ -120,7 +120,7 @@ namespace SixLabors.Memory
public BufferArea<T> GetSubArea(Rectangle rectangle)
{
ImageSharp.DebugGuard.MustBeLessThanOrEqualTo(rectangle.Width, this.Rectangle.Width, nameof(rectangle));
DebugGuard.MustBeLessThanOrEqualTo(rectangle.Height, this.Rectangle.Height, nameof(rectangle));
ImageSharp.DebugGuard.MustBeLessThanOrEqualTo(rectangle.Height, this.Rectangle.Height, nameof(rectangle));
int x = this.Rectangle.X + rectangle.X;
int y = this.Rectangle.Y + rectangle.Y;

Loading…
Cancel
Save