-
Notifications
You must be signed in to change notification settings - Fork 693
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
Unroll Linq in GetFlags #5555
Unroll Linq in GetFlags #5555
Conversation
// PERF: Avoid Linq on hot paths | ||
var splitFlags = flags.Split(CommaArray, StringSplitOptions.RemoveEmptyEntries); | ||
var set = new HashSet<string>(splitFlags.Length, StringComparer.OrdinalIgnoreCase); | ||
for (int i = 0; i < splitFlags.Length; ++i) |
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.
This can just be a foreach as C# will unroll under the covers to this.
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.
There are compile errors, so maybe this can be addressed in the same push @Erarndt
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.
Updated
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 90 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
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.
There's compile errors.
But the general change looks good to me.
Please create a matching issue for these changes.
// PERF: Avoid Linq on hot paths | ||
var splitFlags = flags.Split(CommaArray, StringSplitOptions.RemoveEmptyEntries); | ||
var set = new HashSet<string>(splitFlags.Length, StringComparer.OrdinalIgnoreCase); | ||
for (int i = 0; i < splitFlags.Length; ++i) |
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.
There are compile errors, so maybe this can be addressed in the same push @Erarndt
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 90 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
@Erarndt: Do you have benchmark results? |
Bug
Related: NuGet/Home#12748
Regression? Last working version:
Description
Avoids some allocations due to LINQ usage. Also creates a new list that is sorted in place rather than using
OrderBy
, which internally allocates a buffer for all the items, and then callingToList()
which allocates a list again.PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
Documentation