The ResolvedEvent from EventStore exposes Event.Data and Event.Metadata as ReadOnlyMemory<byte>.
The corresponding Deserialize-Functions accept ReadOnlySpan<byte>.
Therefore calling .ToArray() on the ReadOnlyMemory<byte> creates an unnecessary copy of the data.
By using its property Span we get a ReadOnlySpan<byte> which points to the data.
I haven't run any Benchmark so I don't know the impact of this improvement, but any reduce of GC pressure helps.
But i ran the Tests of Eventuous.Tests.EventStore and it is still all green.
The
ResolvedEventfrom EventStore exposesEvent.DataandEvent.MetadataasReadOnlyMemory<byte>.The corresponding Deserialize-Functions accept
ReadOnlySpan<byte>.Therefore calling
.ToArray()on theReadOnlyMemory<byte>creates an unnecessary copy of the data.By using its property
Spanwe get aReadOnlySpan<byte>which points to the data.I haven't run any Benchmark so I don't know the impact of this improvement, but any reduce of GC pressure helps.
But i ran the Tests of Eventuous.Tests.EventStore and it is still all green.