Skip to content

Commit

Permalink
Merge pull request #227 from Joy-less/add-IDisposable
Browse files Browse the repository at this point in the history
Add IDisposable to ValueStringBuilder
  • Loading branch information
linkdotnet authored Jan 23, 2025
2 parents fb9505c + 7d17255 commit 8fe75ac
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/LinkDotNet.StringBuilder/ValueStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
namespace LinkDotNet.StringBuilder;

/// <summary>
/// Represents a string builder which tried to reduce as much allocations as possible.
/// A string builder which minimizes as many heap allocations as possible.
/// </summary>
/// <remarks>
/// The <see cref="ValueStringBuilder"/> is declared as ref struct which brings certain limitations with it.
/// You can only use it in another ref struct or as a local variable.
/// This is a ref struct which has certain limitations. You can only store it in a local variable or another ref struct.<br/><br/>
/// You should dispose it after use to ensure the rented buffer is returned to the array pool.
/// </remarks>
[StructLayout(LayoutKind.Sequential)]
[SkipLocalsInit]
public ref partial struct ValueStringBuilder
public ref partial struct ValueStringBuilder : IDisposable
{
private int bufferPosition;
private Span<char> buffer;
Expand Down Expand Up @@ -294,7 +294,7 @@ public readonly int LastIndexOf(ReadOnlySpan<char> word, int startIndex)
public readonly bool Equals(ReadOnlySpan<char> span) => span.SequenceEqual(AsSpan());

/// <summary>
/// Disposes the instance and returns rented buffer from an array pool if needed.
/// Disposes the instance and returns the rented buffer to the array pool if needed.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Dispose()
Expand Down

0 comments on commit 8fe75ac

Please sign in to comment.