We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1cef5b0 commit 0e544d5Copy full SHA for 0e544d5
src/LinkDotNet.StringBuilder/ValueStringBuilder.cs
@@ -290,10 +290,14 @@ public readonly void Dispose()
290
[MethodImpl(MethodImplOptions.AggressiveInlining)]
291
private void Grow(int capacity = 0)
292
{
293
- var currentSize = buffer.Length;
+ var size = buffer.Length == 0 ? 8 : buffer.Length;
294
295
- var newSize = capacity > currentSize ? capacity : currentSize * 2;
296
- var rented = ArrayPool<char>.Shared.Rent(newSize);
+ while (size < capacity)
+ {
297
+ size *= 2;
298
+ }
299
+
300
+ var rented = ArrayPool<char>.Shared.Rent(size);
301
buffer[..bufferPosition].CopyTo(rented);
302
var oldBufferFromPool = arrayFromPool;
303
buffer = arrayFromPool = rented;
0 commit comments