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

Conversation

@stephentoub
Copy link
Member

This commit removes several unnecessary char-related allocations in System.IO.FileSystem. Most of them stemmed from appending the DirectorySeparatorChar to a string, which results in the compiler using String.Concat(..., object) for the concatenation, which means the char gets boxed. Others stemmed from array allocations that could have been cached, e.g. allocating an array for the directory separator chars on each call to TrimEnd.

In fixing these, I also noticed and fixed a few places where duplicated logic could be replaced with a call to IsDirectoryChar.

This commit removes several unnecessary char-related allocations in System.IO.FileSystem.  Most of them stemmed from appending the DirectorySeparatorChar to a string, which results in the compiler using String.Concat(..., object) for the concatenation, which means the char gets boxed.  Others stemmed from array allocations that could have been cached, e.g. allocating an array for the directory separator chars on each call to TrimEnd.

In fixing these, I also noticed and fixed a few places where duplicated logic could be replaced with a call to IsDirectoryChar.
@dnfclas
Copy link

dnfclas commented Jan 12, 2015

Hi @stephentoub, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla2.dotnetfoundation.org.

TTYL, DNFBOT;

stephentoub added a commit that referenced this pull request Jan 13, 2015
Remove unnecessary char-related allocations
@stephentoub stephentoub merged commit 03fbac5 into dotnet:master Jan 13, 2015
@stephentoub stephentoub deleted the char_allocs branch January 13, 2015 01:24
@karelz karelz modified the milestone: 1.0.0-rtm Dec 3, 2016
aik-jahoda added a commit to aik-jahoda/corefx that referenced this pull request Mar 15, 2021
* Credentials fixes

* remove dead code

* Update PostScenarioTest.cs

Revert variable name
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tenet-performance Performance related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants