Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

TextInfo: Avoid intermediate allocations in ChangeCase - #1707

Merged
jkotas merged 1 commit into
dotnet:masterfrom
justinvp:changecase
Aug 23, 2016
Merged

jkotas merged 1 commit into
dotnet:masterfrom
justinvp:changecase

Conversation

@justinvp

Copy link
Copy Markdown
Contributor

Avoid unnecessary allocations in TextInfo.ChangeCase on Windows:

  • ChangeCase(char, bool) allocates a temporary string from the source char. Instead, pass the address of the source char to avoid the intermediate string allocation.
  • ChangeCase(string, bool) allocates a temporary char[] buffer, then creates a new string from that buffer. Instead, use string.FastAllocateString to avoid the intermediate buffer allocation, which aligns with the Unix implementation in CoreCLR.

Avoid unnecessary allocations in TextInfo.ChangeCase on Windows:

- ChangeCase(char, bool) allocates a temporary string from the source
char. Instead, pass the address of the source char to avoid the
intermediate string allocation.

- ChangeCase(string, bool) allocates a temporary char[] buffer, then
creates a new string from that buffer. Instead, use
string.FastAllocateString to avoid the intermediate buffer
allocation, which aligns with the Unix implementation in CoreCLR.
@jkotas

jkotas commented Aug 23, 2016

Copy link
Copy Markdown
Member

LGTM. Thanks!

@jkotas
jkotas merged commit 6b96c6a into dotnet:master Aug 23, 2016
@justinvp
justinvp deleted the changecase branch August 23, 2016 17:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants