Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/Akka.Persistence.MongoDb/Journal/MongoDbJournal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,17 @@ await MaybeWithTransaction(async (session, token) =>

private JournalEntry ToJournalEntry(IPersistentRepresentation message)
{
object payload = message.Payload;
List<string> tags;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to an string[] and use Array.Empty<string> to prevent allocations where not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

var payload = message.Payload;
if (message.Payload is Tagged tagged)
{
payload = tagged.Payload;
message = message.WithPayload(payload); // need to update the internal payload when working with tags
tags = tagged.Tags.ToList();
}
else
{
tags = new List<string>();
}

// per https://github.com/akkadotnet/Akka.Persistence.MongoDB/issues/107
Expand All @@ -392,7 +398,7 @@ private JournalEntry ToJournalEntry(IPersistentRepresentation message)
PersistenceId = message.PersistenceId,
SequenceNr = message.SequenceNr,
Manifest = manifest,
Tags = tagged.Tags?.ToList(),
Tags = tags,
SerializerId = null // don't need a serializer ID here either; only for backwards-compat
};
}
Expand All @@ -411,7 +417,7 @@ private JournalEntry ToJournalEntry(IPersistentRepresentation message)
PersistenceId = message.PersistenceId,
SequenceNr = message.SequenceNr,
Manifest = string.Empty, // don't need a manifest here - it's embedded inside the PersistentMessage
Tags = tagged.Tags?.ToList(),
Tags = tags,
SerializerId = null // don't need a serializer ID here either; only for backwards-compat
};
}
Expand Down