@@ -268,6 +268,35 @@ public ArraySegment<T> DangerousGetArray()
268
268
return new ( array ! , 0 , this . index ) ;
269
269
}
270
270
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
+
271
300
/// <summary>
272
301
/// Ensures that <see cref="array"/> has enough free space to contain a given number of new items.
273
302
/// </summary>
@@ -320,35 +349,6 @@ private void ResizeBuffer(int sizeHint)
320
349
this . pool . Resize ( ref this . array , ( int ) minimumSize ) ;
321
350
}
322
351
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
-
352
352
/// <summary>
353
353
/// Throws an <see cref="ArgumentOutOfRangeException"/> when the requested count is negative.
354
354
/// </summary>
0 commit comments