Remove one string allocation in XmlTextEncoder by using stackalloc span and TryFormat#67005
Remove one string allocation in XmlTextEncoder by using stackalloc span and TryFormat#67005TrayanZapryanov wants to merge 1 commit into
Conversation
…using stackalloc char[] and Tryformat
| } | ||
|
|
||
| string strVal = ((int)ch).ToString("X", NumberFormatInfo.InvariantInfo); | ||
| Span<char> chAsSpan = stackalloc char[8]; |
There was a problem hiding this comment.
I am not sure if 8 is the correct value here.
|
Tagging subscribers to this area: @dotnet/area-system-xml Issue DetailsReplace several int.ToString("X", NumberFormatInfo.InvariantInfo) by using stackalloc char[] and Tryformat.
|
|
We had a long discussion about this one in #61774. |
Okay I will close this PR, but let's discuss one idea that popup in my mind for this if you see some value in it. |
|
@TrayanZapryanov I'm ok with making any experimentation if you can see large perf potential benefit. Make sure to write some reasonable benchmarks covering all common scenarios. Technically such TextWriter doesn't really need any changes to the current code as you can technically use it in your own code so perhaps even if this finds useful for very narrow scenarios it might be more of a blog post rather than change and people mind find it useful. I'd suggest start with opening an issue explaining more the idea and if you got some time for experimentation go ahead and share your code and benchmarks used (ideally open an issue once you got some results). Worst case scenario we will not find any benefit and not change anything and close the issue. |
Replace several int.ToString("X", NumberFormatInfo.InvariantInfo) by using stackalloc char[] and Tryformat.