Crate sledgehammer_bindgensource ·
What is Sledgehammer Bindgen?
How does this compare to wasm-bindgen:
You can use sledgehammer bindgen with wasm-bindgen. See the docs and examples for more information.
Why is it fast?
Decoding strings are expensive to decode, but the cost doesn’t change much with the size of the string. Wasm-bindgen calls TextDecoder.decode for every string. Sledgehammer only calls TextEncoder.decode once per batch.
See this benchmark: https://jsbench.me/4vl97c05lb/5
- If the string is static the string will be hashed by pointer instead of by value which is significantly faster.
Byte encoded operations
Every operation is encoded as a sequence of bytes packed into an array. Every operation takes 1 byte plus whatever data is required for it.
See this benchmark: https://jsbench.me/csl9lfauwi/2
- Generates bindings for batched calls to js functions. The generated code is a Buffer struct with methods for each function.