-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Implement LEB128 stdlib #2098
Comments
Hey @furesoft, thanks for raising this. Grain's Number type is a composition of many number subtypes: integers, bigints, floats, rationals. As such, they all have different byte layouts and we wouldn't be able to generically implement an That said though, there are various varint algorithms and I don't think it makes sense to lock While not necessary for a basic implementation, we should really consider SIMD for this because naive LEB128 encoding/decoding is slow. The algorithm to consider would be Vectorized VByte Decoding. It uses 16 SIMD instructions. 15 of them are directly implemented by WebAssembly, with We can probably implement the naive version first, as it will take some time to get SIMD instructions into Grain. |
Instead of a specific We can also add |
Add Buffer.addNumber(Number) that appends the bytes of the number based on the varint algorithm.
Some file formats or protocols rely on that feature so it could be helpful to have this function
The text was updated successfully, but these errors were encountered: