-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Replace new UTF8Encoding(false) #45541
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
Conversation
|
Tagging subscribers to this area: @eiriktsarpalis Issue Details... with
|
|
Thank you for your contribution. If I may ask, what is the motivation for introducing this PR? While it is true that Note that |
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
ae14d9f to
d8a73b8
Compare
|
It's just to eliminate the allocations, I think. |
The allocations are static, not instance. No need to remove. To be meaningful, there may be new static instances for |
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.Unix.cs
Outdated
Show resolved
Hide resolved
In this PR, yes. What do you think of those non-cached allocations among the libraries? Line 110 in f81e708
|
It is not worth changing that CanonicalXml code to remove the UTF8Encoding allocation, as a) the code would need to be complicated to differentiate Windows from Unix (assuming you mean replacing it with Encoding.Default), b) that Encoding allocation is dwarfed by the rest of the allocation happening in that method and its consumers, and c) it's not on a hot path. |
|
Not an issue in this PR, but in general, In general I'm a fan of readability / understandability, even at the expense of a single allocation. If the code requires UTF-8 for correctness, it should be hardcoded against an API that has "utf8" somewhere in the API name. |
... with
Encoding.Defaultsince they are the same.runtime/src/libraries/System.Private.CoreLib/src/System/Text/Encoding.cs
Line 80 in 436284b