Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

CSharpLanguage.ToCSharpString usage of StringBuilder not optimal #3057

Closed
ProfFrugal opened this issue Aug 16, 2023 · 1 comment
Closed

CSharpLanguage.ToCSharpString usage of StringBuilder not optimal #3057

ProfFrugal opened this issue Aug 16, 2023 · 1 comment

Comments

@ProfFrugal
Copy link

Steps to reproduce

  1. Open Perfview, capture a trace
  2. Use ILSpy to do some searching/navigation
  3. Stop trace, check allocation stack

CSharpLanguage.ToCSharpString usage of StringBuilder not optimal, it's calling bunch of StringBuilder.Insert(0, x), then StringBuilder.ToString. In most case, there should be ony a single string, so no allocation is needed.

For more detailed analysis/suggestion: check
https://www.linkedin.com/feed/update/urn:li:activity:7097628892848410624/
https://app.beehiiv.com/posts/b3c9d7bb-56ec-4a71-8070-78e23cbc2c80/analytics

@ProfFrugal ProfFrugal added the Bug label Aug 16, 2023
@christophwille
Copy link
Member

For me only https://frugalcafe.beehiiv.com/p/fc25-icsharpcodeilspycsharplanguage works (found via Twitter).

Did you measure absolute memory usage changes of your approach?

@christophwille christophwille added this to the 8.2 milestone Sep 4, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2024
mattsh247 pushed a commit to mattsh247/ILSpy that referenced this issue Jul 30, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

2 participants