Add StringLiteral#to_utf16#14676
Conversation
|
I didn't run any benchmark. It's probably not so fast because we must transform the |
|
As written in #14670 (comment), almost all of the time required to convert a String to UTF-16 in macro land is caused by the parser. Adding this macro method probably won't be a noticable performance improvement. |
Co-authored-by: Quinton Miller <nicetas.c@gmail.com>
|
@BlobCodes Most likely, yes, but speed ain't my motive. Reusing stdlib means we only implement the algorithm once, and we can have symmetry:
Also, I had fun poking into macro methods: we can return any ASTNode 😈 |
|
Let's benchmark a bit, generating a utf16 slice literal of
I didn't expect the macro method to be noticeably faster. edit: and anyway we don't expect to encode 5000 static UTF-16 strings in a program, and even so the impact is barely noticeable compared to everything else (be it the macro or macro method). |
StringLiteral#to_utf16
Implements the
{{ "hello".to_utf16 }}proposal that merely exposesString#to_utf16to macros.Kept as draft until we decide which form we prefer: macro call or macro method.
closes #14670