Use UTF8 string literals when creating Utf8.TryWriteInterpolatedStringHandlers #74911
Unanswered
Arithmomaniac
asked this question in
Ideas
Replies: 2 comments 5 replies
-
The compiler assumes that |
Beta Was this translation helpful? Give feedback.
5 replies
-
It just occurred to me that this also possibly be "patched in" with a C# interceptor source generator that looks for calls to |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Take the following benchmark code:
Surprisingly, the latter behaves better when I run on LinqPad:
Presumably, this is because the former uses "regular" string interpolation, which carries some cost (certainly when doing AOT compilation):
Whereas the latter uses a compile-time UTF8 literal directly, without any extra conversion:
IMO the compiler should be smart enough to render the latter instead of the former when building
Utf8.TryWriteInterpolatedStringHandler
s.Beta Was this translation helpful? Give feedback.
All reactions