This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Optimize the generic string.Join for length 1 collections#6463
Merged
Conversation
There was a problem hiding this comment.
Nit: Could save a local and declare T currentValue here
|
Some minor comments. LGTM |
Author
|
@bbowyersmyth Thanks for the feedback! I've pushed another commit that fixes the nits. |
Member
|
The Ubuntu failure is issue #6222. |
Member
|
@dotnet-bot test Ubuntu x64 Checked Build and Test |
Author
|
@jkotas PTAL @adityamandaleeka Thank you for restarting the CI. |
Member
|
LGTM. The Ubuntu CI failed again with #6222. |
picenka21
pushed a commit
to picenka21/runtime
that referenced
this pull request
Feb 18, 2022
…eclr#6463) * Optimize the generic string.Join for length 1 collections * Keep the call order consistent: MoveNext-Current-ToString * Convert to do..while loop to reduce code duplication Commit migrated from dotnet/coreclr@dcd9aae
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.
I noticed an optimization made by @bbowyersmyth for
Joinsome time ago for single-item lists-- (#1460) but it looks like it wasn't done for the generic version. The one that accepts anIEnumerable<T>is a little trickier to optimize since you need to handle the fact that eithercurrentValueor itsToStringcould be null, but here it is.Notes:
MoveNext/Current/ToString, in case for some bizarre reason one of the latter 2 modify state.private conststhat are not used anywhere), so I removed that.CoreFX tests already exist for this overload, including for objects with
ToStringreturning null.cc @jkotas @bbowyersmyth @AlexGhiondea