From 56da8fd120c47ded05ede829f126bb7ffc1d2ae7 Mon Sep 17 00:00:00 2001
From: Joyless <65855333+Joy-less@users.noreply.github.com>
Date: Thu, 23 Jan 2025 19:43:44 +0000
Subject: [PATCH 1/2] Add IDisposable
---
src/LinkDotNet.StringBuilder/ValueStringBuilder.cs | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs b/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs
index b190a44..565afb2 100644
--- a/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs
+++ b/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs
@@ -5,15 +5,15 @@
namespace LinkDotNet.StringBuilder;
///
-/// Represents a string builder which tried to reduce as much allocations as possible.
+/// A string builder which minimizes as many heap allocations as possible.
///
///
-/// The 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.
///
[StructLayout(LayoutKind.Sequential)]
[SkipLocalsInit]
-public ref partial struct ValueStringBuilder
+public ref partial struct ValueStringBuilder : IDisposable
{
private int bufferPosition;
private Span buffer;
From 7d17255de9a8ee40fa6478725da16188c14bfc12 Mon Sep 17 00:00:00 2001
From: Joyless <65855333+Joy-less@users.noreply.github.com>
Date: Thu, 23 Jan 2025 19:46:17 +0000
Subject: [PATCH 2/2] Add dispose to doc comment
---
src/LinkDotNet.StringBuilder/ValueStringBuilder.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs b/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs
index 565afb2..771b920 100644
--- a/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs
+++ b/src/LinkDotNet.StringBuilder/ValueStringBuilder.cs
@@ -8,8 +8,8 @@ namespace LinkDotNet.StringBuilder;
/// A string builder which minimizes as many heap allocations as possible.
///
///
-/// This is a ref struct which has certain limitations.
-/// You can only store it in a local variable or another ref struct.
+/// This is a ref struct which has certain limitations. You can only store it in a local variable or another ref struct.
+/// You should dispose it after use to ensure the rented buffer is returned to the array pool.
///
[StructLayout(LayoutKind.Sequential)]
[SkipLocalsInit]
@@ -294,7 +294,7 @@ public readonly int LastIndexOf(ReadOnlySpan word, int startIndex)
public readonly bool Equals(ReadOnlySpan span) => span.SequenceEqual(AsSpan());
///
- /// 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.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Dispose()