Skip to content
Merged
Changes from all 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
15 changes: 9 additions & 6 deletions src/core/Akka/Event/LogMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,15 @@ public IReadOnlyDictionary<string, object> GetProperties()
// Optimize: avoid ToArray() if Parameters() already returns IReadOnlyList
if (parameters is IReadOnlyList<object> readOnlyList)
{
_properties = CreatePropertyDictionary(PropertyNames, readOnlyList);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

if (readOnlyList.Count == 0)
{
// Optimize: Skips parsing PropertyNames when empty Parameters()
_properties = EmptyDictionary;
}
else
{
_properties = CreatePropertyDictionary(PropertyNames, readOnlyList);
}
}
else
{
Expand Down Expand Up @@ -109,12 +117,7 @@ private static IReadOnlyDictionary<string, object> CreatePropertyDictionary(
dict[names[i]] = values[i];
}

#if NET8_0_OR_GREATER
// Use FrozenDictionary for optimal read performance on .NET 8+
return System.Collections.Frozen.FrozenDictionary.ToFrozenDictionary(dict);
#else
return dict;
#endif
}

private static readonly IReadOnlyDictionary<string, object> EmptyDictionary =
Expand Down
Loading