-
Notifications
You must be signed in to change notification settings - Fork 7
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
Uint8Array to UTF8 conversion #3
Comments
Sure thing, let's do it! |
Here's the current state of TextDecoder in main branch.
|
Do you have a benchmark comparing it to Buffer.toString? |
Do you have a link to the benchmark code? |
Also do you compare buf.toString() vs TextEncoder.encode(buf), i.e. excluding the Buffer.from overhead? |
Here's the full benchmark: https://github.com/anonrig/node-benchmarks/blob/main/text-encoder/index.mjs |
I'm closing now, since the text decoder is much more performant right now for utf-8. |
I see that
undici
is mostly usingBuffer.from(name).toString('utf8')
. This crosses the JS-C++ boundary 2 times. 1 for initializing, and 1 fortoString
.I recommend implementing a function like this:
Buffer.asString(name, encoding)
which returnsstring
Buffer.asStrings([first, second], encoding)
which returnsstring[]
The text was updated successfully, but these errors were encountered: