Browse Source

[SL.Core] drop meaningless upper limit check

af/octree-no-pixelmap
Anton Firszov 7 years ago
parent
commit
e21eb5d18f
  1. 1
      src/SixLabors.Core/Memory/ArrayPoolMemoryAllocator.cs
  2. 2
      src/SixLabors.Core/Memory/SimpleGcMemoryAllocator.cs
  3. 1
      tests/SixLabors.Core.Tests/Memory/ArrayPoolMemoryAllocatorTests.cs
  4. 2
      tests/SixLabors.Core.Tests/Memory/SimpleGcMemoryAllocatorTests.cs

1
src/SixLabors.Core/Memory/ArrayPoolMemoryAllocator.cs

@ -118,7 +118,6 @@ namespace SixLabors.Memory
public override IManagedByteBuffer AllocateManagedByteBuffer(int length, AllocationOptions options = AllocationOptions.None)
{
Guard.MustBeGreaterThanOrEqualTo(length, 0, nameof(length));
Guard.MustBeLessThan(length, int.MaxValue, nameof(length));
ArrayPool<byte> pool = this.GetArrayPool(length);
byte[] byteArray = pool.Rent(length);

2
src/SixLabors.Core/Memory/SimpleGcMemoryAllocator.cs

@ -16,7 +16,6 @@ namespace SixLabors.Memory
public override IMemoryOwner<T> Allocate<T>(int length, AllocationOptions options = AllocationOptions.None)
{
Guard.MustBeGreaterThanOrEqualTo(length, 0, nameof(length));
Guard.MustBeLessThan(length, int.MaxValue, nameof(length));
return new BasicArrayBuffer<T>(new T[length]);
}
@ -25,7 +24,6 @@ namespace SixLabors.Memory
public override IManagedByteBuffer AllocateManagedByteBuffer(int length, AllocationOptions options = AllocationOptions.None)
{
Guard.MustBeGreaterThanOrEqualTo(length, 0, nameof(length));
Guard.MustBeLessThan(length, int.MaxValue, nameof(length));
return new BasicByteBuffer(new byte[length]);
}

1
tests/SixLabors.Core.Tests/Memory/ArrayPoolMemoryAllocatorTests.cs

@ -249,7 +249,6 @@ namespace SixLabors.Memory.Tests
[Theory]
[InlineData(-1)]
[InlineData(int.MaxValue)]
public void AllocateManagedByteBuffer_IncorrectAmount_ThrowsCorrect_ArgumentOutOfRangeException(int length)
{
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => this.MemoryAllocator.AllocateManagedByteBuffer(length));

2
tests/SixLabors.Core.Tests/Memory/SimpleGcMemoryAllocatorTests.cs

@ -21,7 +21,6 @@ namespace SixLabors.Memory.Tests
[Theory]
[InlineData(-1)]
[InlineData(int.MaxValue)]
public void Allocate_IncorrectAmount_ThrowsCorrect_ArgumentOutOfRangeException(int length)
{
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => this.MemoryAllocator.Allocate<BigStruct>( length));
@ -30,7 +29,6 @@ namespace SixLabors.Memory.Tests
[Theory]
[InlineData(-1)]
[InlineData(int.MaxValue)]
public void AllocateManagedByteBuffer_IncorrectAmount_ThrowsCorrect_ArgumentOutOfRangeException(int length)
{
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => this.MemoryAllocator.AllocateManagedByteBuffer(length));

Loading…
Cancel
Save