Skip to content

Use params and char overload #4231

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

Merged
merged 1 commit into from
Aug 10, 2022

Conversation

ThomasGoulet73
Copy link
Contributor

Description

Uses the single char overload instead of the one using char array.

Note: PresentationBuildTasks targets .Net Framework 4.7.2 and .Net Core 2.1. The method string.Split(char) was introduced in .Net Core 2.0 so the changes do not apply to .Net Framework. .Net Framework 4.7.2 will call string.Split(params char[]) and .Net Core 2.1 will call string.Split(char).

Thoses changes should give a small perf gain and reduce memory usage.

Here is the result for the method string.Split on my machine:

Method str Mean Error StdDev Ratio Gen 0 Gen 1 Gen 2 Allocated
CharArray 123456789,123456789 55.03 ns 0.562 ns 0.469 ns 1.00 0.0242 - - 152 B
Char 123456789,123456789 51.92 ns 0.193 ns 0.162 ns 0.94 0.0191 - - 120 B
CharArray 123456789123456789 26.66 ns 0.157 ns 0.131 ns 1.00 0.0102 - - 64 B
Char 123456789123456789 23.84 ns 0.081 ns 0.076 ns 0.89 0.0051 - - 32 B

Customer Impact

Regression

Testing

Risk

There is a risk that the behavior for the method overload using char array is not the same as the one using a single char but since those method are in the BCL, I think the risk is very low.

@ThomasGoulet73 ThomasGoulet73 requested a review from a team as a code owner March 1, 2021 15:06
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Mar 1, 2021
@ghost ghost requested review from fabiant3, ryalanms and SamBent March 1, 2021 15:06
@ryalanms ryalanms added the Performance Performance related issue label Mar 1, 2021
Base automatically changed from master to main March 17, 2021 17:38
@pchaurasia14 pchaurasia14 added the Community Contribution A label for all community Contributions label Jul 20, 2022
@dipeshmsft dipeshmsft merged commit 7852ebf into dotnet:main Aug 10, 2022
@ThomasGoulet73 ThomasGoulet73 deleted the use-params-and-char-overload branch August 10, 2022 16:33
@ghost ghost locked as resolved and limited conversation to collaborators Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Community Contribution A label for all community Contributions Performance Performance related issue PR metadata: Label to tag PRs, to facilitate with triage
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants