This fixes the Message's Reset() call to allow reuse of the first segment.
Prior to this fix, the first segment was discarded after the first Reset call, effectively causing a new segment to be initialized on every Reset call.
By reusing the first segment, the number of heap allocations is reduced and therefore performance is increased in use cases where the message object is reused.
The fix involved associtating the segment to the message and fixing checks to ensure the data of the segment is re-allocated after the reset.
A benchmark is included to show the current performance of this.
This fixes the Message's Reset() call to allow reuse of the first segment.
Prior to this fix, the first segment was discarded after the first Reset call, effectively causing a new segment to be initialized on every Reset call.
By reusing the first segment, the number of heap allocations is reduced and therefore performance is increased in use cases where the message object is reused.
The fix involved associtating the segment to the message and fixing checks to ensure the data of the segment is re-allocated after the reset.
A benchmark is included to show the current performance of this.
Part of #554