-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Buffers
Milestone
Description
Background and Motivation
Currently there is no way to reset an ArrayBufferWriter<T>
without zeroing the underlying memory, which can be expensive and an entirely unnecessary cost often.
Proposed API
namespace System.Buffers
{
public class ArrayBufferWriter<T> : IBufferWriter<T>
{
+ public void Reset();
}
}
Usage Examples
When building short-lived buffers in high performance scenarios (for example, to generate command buffers to be sent over PCIE or network to control physical devices), being able to quickly reset the buffer writer is helpful, and zeroing is an unnecessary expense.
Alternative Designs
It could alternatively be an overload of Clear
:
public void Clear(bool zeroBackingArray);
Risks
Types which contain references should probably still be cleared to allow collection.
Frassle, geeknoid, Jure-BB, JeremyTCD, EduardSergeev and 1 more
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Buffers