From e21eb5d18f7074ff022373dc068f52dbb85a351b Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sun, 21 Apr 2019 00:56:40 +0200 Subject: [PATCH] [SL.Core] drop meaningless upper limit check --- src/SixLabors.Core/Memory/ArrayPoolMemoryAllocator.cs | 1 - src/SixLabors.Core/Memory/SimpleGcMemoryAllocator.cs | 2 -- .../Memory/ArrayPoolMemoryAllocatorTests.cs | 1 - .../SixLabors.Core.Tests/Memory/SimpleGcMemoryAllocatorTests.cs | 2 -- 4 files changed, 6 deletions(-) diff --git a/src/SixLabors.Core/Memory/ArrayPoolMemoryAllocator.cs b/src/SixLabors.Core/Memory/ArrayPoolMemoryAllocator.cs index 0a5e47f28..113e12785 100644 --- a/src/SixLabors.Core/Memory/ArrayPoolMemoryAllocator.cs +++ b/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 pool = this.GetArrayPool(length); byte[] byteArray = pool.Rent(length); diff --git a/src/SixLabors.Core/Memory/SimpleGcMemoryAllocator.cs b/src/SixLabors.Core/Memory/SimpleGcMemoryAllocator.cs index fc7fb607f..acf17ad63 100644 --- a/src/SixLabors.Core/Memory/SimpleGcMemoryAllocator.cs +++ b/src/SixLabors.Core/Memory/SimpleGcMemoryAllocator.cs @@ -16,7 +16,6 @@ namespace SixLabors.Memory public override IMemoryOwner Allocate(int length, AllocationOptions options = AllocationOptions.None) { Guard.MustBeGreaterThanOrEqualTo(length, 0, nameof(length)); - Guard.MustBeLessThan(length, int.MaxValue, nameof(length)); return new BasicArrayBuffer(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]); } diff --git a/tests/SixLabors.Core.Tests/Memory/ArrayPoolMemoryAllocatorTests.cs b/tests/SixLabors.Core.Tests/Memory/ArrayPoolMemoryAllocatorTests.cs index 5226c9b01..e59590bae 100644 --- a/tests/SixLabors.Core.Tests/Memory/ArrayPoolMemoryAllocatorTests.cs +++ b/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(() => this.MemoryAllocator.AllocateManagedByteBuffer(length)); diff --git a/tests/SixLabors.Core.Tests/Memory/SimpleGcMemoryAllocatorTests.cs b/tests/SixLabors.Core.Tests/Memory/SimpleGcMemoryAllocatorTests.cs index 96f92e682..86e71717e 100644 --- a/tests/SixLabors.Core.Tests/Memory/SimpleGcMemoryAllocatorTests.cs +++ b/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(() => this.MemoryAllocator.Allocate( 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(() => this.MemoryAllocator.AllocateManagedByteBuffer(length));