-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed temporary array allocations for properties #1948
Conversation
I'm not sure it's worth (and possible) to optimize the default https://github.com/dotnet/csharplang/blob/main/proposals/params-span.md |
8bce52c
to
3b7311a
Compare
Thanks - this looks like a nice option 👍 - may take some more time to review. |
I think this is the way to go - looks like CI produced some failures, though. |
{ | ||
if (messageTemplateParameters == null || messageTemplateParameters.Length == 0) | ||
if (messageTemplateParameters.Length == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be worth including a few quick speculative tests to check that removing the == null
test here is safe even when callers without strict null checking enabled call various logger methods, e.g.:
[Fact]
public void NullMessageTemplateParametersDoNotBreakBinding()
{
var log = new LoggerConfiguration().WriteTo.Sink(new CollectingSink()).CreateLogger();
log.Information("test", (object?[]?) null);
log.BindMessageTemplate("test", (object?[]?)null, out _, out _);
}
?
192b494
to
0b60bc6
Compare
0b60bc6
to
ee6dd12
Compare
Similar to #1779, but uses on-stack allocation instead of pooling.