-
Notifications
You must be signed in to change notification settings - Fork 8
Fast conversion to/from ASCII/one-byte strings? #44
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
Comments
From a dart2wasm perspective I tend to agree that there should be a fast mechanism to create a JS string from an WasmGC array of bytes that contain ascii - as this is extremely common thing. Imagine the app that operates on a binary encoding of a message that has some structure (e.g. protobuf, flatbuffer, ...). Such messages can have strings in them. The message is going to be a WasmGC array of bytes and sub-sections of them are encoded strings. The common case being just ascii encoded strings. The utf-8 decoding implementation written in WasmGC will scan the utf-8 encoded string to find out the string length and during this pass will also find out whether it's ascii or not. => If it's ascii we'd like to directly call a This would avoid
I think this would still align with:
As this isn't about adding utf-8 support to the the If wasm allows duplicate imports (see e.g. WebAssembly/design#1402) one could even specify that one can import the same name /cc @eqrion Is this something that could be included before /cc @osa1 |
As a tangential note: The stated goals of the
Though the lines are very bury here because the
|
I just realized I forgot one other function that should've been in that proposal: Also should note that while this proposal is titled |
It was pointed out to me that the So I guess this is too late to adjust the |
Yes, now that this is phase 4 (and shipping in some browsers) we can't really change it. But I do intend to do a follow up proposal in the future with more extensions. So this could be worthwhile then. |
It's a near universal optimization within JS implementations to split strings into two representations: a one-byte and a two-byte. Even the size-optimized runtime XS does it. It brings a massive speed boost and almost halves string memory usage in practice. So, I'd like to see
fromCharByteArray
andintoCharByteArray
that return character codes modulo 256.The text was updated successfully, but these errors were encountered: