-
-
Notifications
You must be signed in to change notification settings - Fork 234
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
Faster toString('hex')
implementation
#364
Comments
Thinking about it, we can probably limit the extra memory needed by doing it in chunks ... |
I've packaged this code up on npm: https://www.npmjs.com/package/hextreme. For multi-megabyte arrays it can be many times faster than the approach currently taken here. Are you willing to consider a PR to use this package for |
I think we reasonably track Node LTS for the |
Thanks. I actually added a fallback implementation where there's no I also limited the biggest possible temporary buffer allocation to 1MB, by doing the conversion in chunks, which makes very little difference in speed. I'll go ahead and submit a PR in the next few days then. |
I've actually just applied the same technique to base64 encoding, so I might submit another PR for that at some point. |
In a similar vein to #245, I have an implementation of
toString('hex')
that's between 2x and 4x faster than the existing one, depending on the browser/engine.See: https://jsbench.me/evm3ejel2i/3
Possible drawbacks of this implementation:
TextDecoder
(does this package support IE currently?)Uint16Array
to hold intermediate dataWould you accept a PR to switch to this implementation?
The text was updated successfully, but these errors were encountered: