-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add StringLiteral#to_utf16
#14676
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 <[email protected]>
@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_utf16
to macros.Kept as draft until we decide which form we prefer: macro call or macro method.
closes #14670