Skip to content

Commit 324235d

Browse files
committed
Fix members ordering in ArrayPoolBufferWriter<T>
1 parent 0ec2c25 commit 324235d

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

src/CommunityToolkit.HighPerformance/Buffers/ArrayPoolBufferWriter{T}.cs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,35 @@ public ArraySegment<T> DangerousGetArray()
268268
return new(array!, 0, this.index);
269269
}
270270

271+
/// <inheritdoc/>
272+
public void Dispose()
273+
{
274+
T[]? array = this.array;
275+
276+
if (array is null)
277+
{
278+
return;
279+
}
280+
281+
this.array = null;
282+
283+
this.pool.Return(array);
284+
}
285+
286+
/// <inheritdoc/>
287+
public override string ToString()
288+
{
289+
// See comments in MemoryOwner<T> about this
290+
if (typeof(T) == typeof(char) &&
291+
this.array is char[] chars)
292+
{
293+
return new(chars, 0, this.index);
294+
}
295+
296+
// Same representation used in Span<T>
297+
return $"CommunityToolkit.HighPerformance.Buffers.ArrayPoolBufferWriter<{typeof(T)}>[{this.index}]";
298+
}
299+
271300
/// <summary>
272301
/// Ensures that <see cref="array"/> has enough free space to contain a given number of new items.
273302
/// </summary>
@@ -320,35 +349,6 @@ private void ResizeBuffer(int sizeHint)
320349
this.pool.Resize(ref this.array, (int)minimumSize);
321350
}
322351

323-
/// <inheritdoc/>
324-
public void Dispose()
325-
{
326-
T[]? array = this.array;
327-
328-
if (array is null)
329-
{
330-
return;
331-
}
332-
333-
this.array = null;
334-
335-
this.pool.Return(array);
336-
}
337-
338-
/// <inheritdoc/>
339-
public override string ToString()
340-
{
341-
// See comments in MemoryOwner<T> about this
342-
if (typeof(T) == typeof(char) &&
343-
this.array is char[] chars)
344-
{
345-
return new(chars, 0, this.index);
346-
}
347-
348-
// Same representation used in Span<T>
349-
return $"CommunityToolkit.HighPerformance.Buffers.ArrayPoolBufferWriter<{typeof(T)}>[{this.index}]";
350-
}
351-
352352
/// <summary>
353353
/// Throws an <see cref="ArgumentOutOfRangeException"/> when the requested count is negative.
354354
/// </summary>

0 commit comments

Comments
 (0)