Skip to content

Avoid unnecessary copy of Payload and Metadata in EsdbEventStore #199

@k3daevin

Description

@k3daevin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions