Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IDisposable to ValueStringBuilder #227

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading