Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Further optimizations for String.Join, String.Concat#6800

Merged
jkotas merged 6 commits into
dotnet:masterfrom
jamesqo:more-join-concat-optimizations
Aug 22, 2016
Merged

Further optimizations for String.Join, String.Concat#6800
jkotas merged 6 commits into
dotnet:masterfrom
jamesqo:more-join-concat-optimizations

Conversation

@jamesqo
Copy link
Copy Markdown

@jamesqo jamesqo commented Aug 18, 2016

Changes:

  • We call the IEnumerable<string> based overload in the generic overloads, if typeof(T) == typeof(string). This can happen practically if someone has a GenericMethod<T> that calls Concat/Join, and then someone calls that method with T == string.
  • Optimize more Join/Concat overloads for length 0-and-1 collections by not allocating anything.
  • Cleanup some of the code.

cc @jkotas, @bbowyersmyth

Tests are dotnet/corefx#10966

Comment thread src/mscorlib/src/System/String.cs Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think that this optimization is worth the extra code.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkotas Sure, removed the optimizations.

@ghost
Copy link
Copy Markdown

ghost commented Aug 20, 2016

@jamesqo, this will produce merge conflicts with #2945, which is similar to #895.

@jamesqo
Copy link
Copy Markdown
Author

jamesqo commented Aug 21, 2016

@jasonwilliams200OK I have opened up a pull request in your fork which I believe should remove the merge conflicts with this PR.

@jamesqo
Copy link
Copy Markdown
Author

jamesqo commented Aug 21, 2016

@jkotas Is this OK to be merged? I will port the changes to the CoreRT repo if it's ready.

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Aug 22, 2016

LGTM. Thanks!

@jkotas jkotas merged commit d39efa7 into dotnet:master Aug 22, 2016
@jamesqo jamesqo deleted the more-join-concat-optimizations branch August 22, 2016 02:00
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…6800)

* Apply length-1 optimization to Join(string, object[])
* Apply length-1 optimization to Concat(IEnumerable<string>)
* Apply length-1 optimization to Concat(IEnumerable<T>)
* Apply lengths 0/1 optimizations to Concat(object[]), Concat(string[])

Commit migrated from dotnet/coreclr@d39efa7
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants