This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Optimize ToArray for non-empty enumerables - #2668
Closed
jamesqo wants to merge 2 commits into
Closed
Conversation
Member
There was a problem hiding this comment.
With this change, all of the accesses in this method are now field accesses rather than local accesses. You've verified that doesn't harm the generated assembly?
Member
There was a problem hiding this comment.
+1 here.
Keeping items and count as locals until the copying is done can be beneficial, so I'd preserve that. The change removes one null check (that seems to be very predictable), so perf benefit of that might be relatively small and I wonder if introducing field accesses may actually make things slower.
- can we keep items/count as locals until done copying?
- what speedup are we looking at here overall?
Member
|
cc: @VSadov |
Contributor
Author
|
Closed because of dupe @ #2871. |
JonHanna
added a commit
to JonHanna/corefx
that referenced
this pull request
Aug 18, 2015
…e use of locals. One use of goto, but perhaps worth the velociraptor risk.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Separated from PR #2318. This does not negatively impact empty collections, and behavior for
Buffer<T>.ToArray()shouldn't change.