WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@TimothyMakkison
Copy link

Removes unnecessary ToArray calls

Copy link
Member

@mgravell mgravell left a comment

Choose a reason for hiding this comment

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

Looks good; I'll need to double check impact on the full TFM range (i.e. the older overloads), but: 👍


// Before we get all emitty...
var lookup = string.Join("|", names.ToArray());
var lookup = string.Join("|", names);

Choose a reason for hiding this comment

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

A "char" vs "string" can be used in Join() call.

Copy link
Author

@TimothyMakkison TimothyMakkison Dec 29, 2025

Choose a reason for hiding this comment

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

I'm scared of getting nerd sniped here, but I'm pretty sure they do the same thing. string.Join(char and string.Join(string. both call JoinCore. The only difference is it converts the char into a Span via new ReadOnlySpan<char>(in separator) before calling JoinCore. Code here

I would love to know if the generated code is different between char and string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants