Skip to content

Commit fcac967

Browse files
committed
refactor: Removed defensive check
1 parent a1c723a commit fcac967

File tree

3 files changed

+3
-22
lines changed

3 files changed

+3
-22
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ All notable changes to **ValueStringBuilder** will be documented in this file. T
66

77
## [Unreleased]
88

9+
### Changed
10+
- Remove unused defensive check in `EnsureCapacity`
11+
912
## [1.13.0] - 2023-03-04
1013

1114
### Added

src/LinkDotNet.StringBuilder/ValueStringBuilder.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,6 @@ public ValueStringBuilder(ReadOnlySpan<char> initialText)
159159
[MethodImpl(MethodImplOptions.AggressiveInlining)]
160160
public void EnsureCapacity(int newCapacity)
161161
{
162-
if (newCapacity < 0)
163-
{
164-
throw new ArgumentOutOfRangeException(nameof(newCapacity), "Capacity can't be negative.");
165-
}
166-
167162
if (newCapacity > Length)
168163
{
169164
Grow(newCapacity);

tests/LinkDotNet.StringBuilder.UnitTests/ValueStringBuilderTests.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -259,23 +259,6 @@ public void ShouldNotSetCapacityWhenSmallerThanCurrentString()
259259
builder.Length.Should().BeGreaterOrEqualTo(128);
260260
}
261261

262-
[Fact]
263-
public void ShouldThrowWhenNegativeValueInEnsureCapacity()
264-
{
265-
using var builder = new ValueStringBuilder();
266-
try
267-
{
268-
builder.EnsureCapacity(-1);
269-
}
270-
catch (ArgumentOutOfRangeException)
271-
{
272-
Assert.True(true);
273-
return;
274-
}
275-
276-
Assert.False(true);
277-
}
278-
279262
[Fact]
280263
public void ShouldFindLastOccurence()
281264
{

0 commit comments

Comments
 (0)