-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Labels
area-Extensions-Loggingneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsideration
Milestone
Description
Maybe this code:
runtime/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/FormattedLogValues.cs
Lines 63 to 73 in 96acc3c
| public KeyValuePair<string, object?> this[int index] | |
| { | |
| get | |
| { | |
| if (index < 0 || index >= Count) | |
| { | |
| throw new IndexOutOfRangeException(); | |
| } | |
| if (index == Count - 1) | |
| { |
Can be optimized to single Count-Lookup like this:
public KeyValuePair<string, object?> this[int index]
{
get
{
var parameterCount = Count;
if (index < 0 || index >= parameterCount)
{
throw new IndexOutOfRangeException();
}
if (index == parameterCount - 1) Since Count is a "complex" method:
runtime/src/libraries/Microsoft.Extensions.Logging.Abstractions/src/FormattedLogValues.cs
Lines 81 to 90 in 96acc3c
| public int Count | |
| { | |
| get | |
| { | |
| if (_formatter == null) | |
| { | |
| return 1; | |
| } | |
| return _formatter.ValueNames.Count + 1; |
Metadata
Metadata
Assignees
Labels
area-Extensions-Loggingneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsideration