Skip to content

Commit 78dfa7b

Browse files
author
LinkDotNet Bot
committed
Updating to newest release
2 parents a575a0a + 043874b commit 78dfa7b

File tree

9 files changed

+45
-9
lines changed

9 files changed

+45
-9
lines changed

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Checkout repository
2525
uses: actions/[email protected]
2626

27-
- uses: actions/setup-dotnet@v4.2.0
27+
- uses: actions/setup-dotnet@v4.3.0
2828
with:
2929
dotnet-version: |
3030
8.0.x

.github/workflows/create-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
path: ./CHANGELOG.md
3535

3636
- name: Setup dotnet
37-
uses: actions/setup-dotnet@v4.2.0
37+
uses: actions/setup-dotnet@v4.3.0
3838
with:
3939
dotnet-version: |
4040
8.0.x

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/[email protected]
1616

1717
- name: Setup .NET
18-
uses: actions/setup-dotnet@v4.2.0
18+
uses: actions/setup-dotnet@v4.3.0
1919
with:
2020
dotnet-version: |
2121
8.0.x

.github/workflows/dotnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/[email protected]
1616
- name: Setup .NET
17-
uses: actions/setup-dotnet@v4.2.0
17+
uses: actions/setup-dotnet@v4.3.0
1818
with:
1919
dotnet-version: |
2020
8.0.x

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ All notable changes to **ValueStringBuilder** will be documented in this file. T
66

77
## [Unreleased]
88

9+
## [2.3.0] - 2025-02-16
10+
11+
### Added
12+
13+
- Added `Equals(ReadOnlySpan<char>, StringComparison)` (by @Joy-less in #234)
14+
15+
### Changed
16+
17+
- Improved `Equals(ReadOnlySpan<char>)` (by @Joy-less in #234)
18+
- Added performance short-circuit when span is empty in `Append(ReadOnlySpan<char>)`, `AppendSpan(int)`, `Insert(int, ReadOnlySpan<char>)` in #233 (by @Joy-less)
19+
920
## [2.2.0] - 2025-01-25
1021

1122
### Added
@@ -456,7 +467,8 @@ This release brings extensions to the `ValueStringBuilder` API. For `v1.0` the `
456467

457468
- Initial release
458469

459-
[unreleased]: https://github.com/linkdotnet/StringBuilder/compare/2.2.0...HEAD
470+
[unreleased]: https://github.com/linkdotnet/StringBuilder/compare/2.3.0...HEAD
471+
[2.3.0]: https://github.com/linkdotnet/StringBuilder/compare/2.2.0...2.3.0
460472
[2.2.0]: https://github.com/linkdotnet/StringBuilder/compare/2.1.0...2.2.0
461473
[2.1.0]: https://github.com/linkdotnet/StringBuilder/compare/2.0.0...2.1.0
462474
[2.0.0]: https://github.com/linkdotnet/StringBuilder/compare/1.22.0...2.0.0

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup>
4-
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.5.0.109200">
4+
<PackageReference Include="SonarAnalyzer.CSharp" Version="10.6.0.109712">
55
<PrivateAssets>all</PrivateAssets>
66
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
77
</PackageReference>

src/LinkDotNet.StringBuilder/ValueStringBuilder.Append.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public void Append<T>(T value, ReadOnlySpan<char> format = default, int bufferSi
6464
[MethodImpl(MethodImplOptions.AggressiveInlining)]
6565
public void Append(scoped ReadOnlySpan<char> str)
6666
{
67+
if (str.IsEmpty)
68+
{
69+
return;
70+
}
71+
6772
var newSize = str.Length + bufferPosition;
6873
if (newSize > buffer.Length)
6974
{
@@ -160,6 +165,11 @@ public void AppendLine(scoped ReadOnlySpan<char> str)
160165
[MethodImpl(MethodImplOptions.AggressiveInlining)]
161166
public Span<char> AppendSpan(int length)
162167
{
168+
if (length == 0)
169+
{
170+
return [];
171+
}
172+
163173
var origPos = bufferPosition;
164174
if (origPos > buffer.Length - length)
165175
{

src/LinkDotNet.StringBuilder/ValueStringBuilder.Insert.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ public void Insert(int index, scoped ReadOnlySpan<char> value)
6666
throw new ArgumentOutOfRangeException(nameof(index), "The given index can't be bigger than the string itself.");
6767
}
6868

69+
if (value.IsEmpty)
70+
{
71+
return;
72+
}
73+
6974
var newLength = bufferPosition + value.Length;
7075
if (newLength > buffer.Length)
7176
{

src/LinkDotNet.StringBuilder/ValueStringBuilder.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public readonly int LastIndexOf(ReadOnlySpan<char> word, int startIndex)
243243
}
244244

245245
/// <summary>
246-
/// Returns a value indicating whether a specified substring occurs within this string.
246+
/// Returns whether a specified substring occurs within this string.
247247
/// </summary>
248248
/// <param name="word">Word to look for in this string.</param>
249249
/// <returns>True if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false.</returns>
@@ -254,12 +254,21 @@ public readonly int LastIndexOf(ReadOnlySpan<char> word, int startIndex)
254254
public readonly bool Contains(ReadOnlySpan<char> word) => IndexOf(word) != -1;
255255

256256
/// <summary>
257-
/// Returns a value indicating whether the characters in this instance are equal to the characters in a specified read-only character span.
257+
/// Returns whether the characters in this builder are equal to the characters in the given span.
258258
/// </summary>
259259
/// <param name="span">The character span to compare with the current instance.</param>
260260
/// <returns><see langword="true"/> if the characters are equal to this instance, otherwise <see langword="false"/>.</returns>
261261
[MethodImpl(MethodImplOptions.AggressiveInlining)]
262-
public readonly bool Equals(ReadOnlySpan<char> span) => span.SequenceEqual(AsSpan());
262+
public readonly bool Equals(ReadOnlySpan<char> span) => span.Equals(AsSpan(), StringComparison.Ordinal);
263+
264+
/// <summary>
265+
/// Returns whether the characters in this builder are equal to the characters in the given span according to the given comparison type.
266+
/// </summary>
267+
/// <param name="span">The character span to compare with the current instance.</param>
268+
/// <param name="comparisonType">The way to compare the sequences of characters.</param>
269+
/// <returns><see langword="true"/> if the characters are equal to this instance, otherwise <see langword="false"/>.</returns>
270+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
271+
public readonly bool Equals(ReadOnlySpan<char> span, StringComparison comparisonType) => span.Equals(AsSpan(), comparisonType);
263272

264273
/// <summary>
265274
/// Disposes the instance and returns the rented buffer to the array pool if needed.

0 commit comments

Comments
 (0)