forked from rustwasm/wasm-bindgen
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
TextEncoder#encodeInto
This commit adds support for the recently implemented standard of [`TextEncoder#encodeInto`][standard]. This new function is a "bring your own buffer" style function where we can avoid an intermediate allocation and copy by encoding strings directly into wasm's memory. Currently we feature-detect whether `encodeInto` exists as it is only implemented in recent browsers and not in all browsers. Additionally this commit emits the binding using `encodeInto` by default, but this requires `realloc` functionality to be exposed by the wasm module. Measured locally an empty binary which takes `&str` previously took 7.6k, but after this commit takes 8.7k due to the extra code needed for `realloc`. [standard]: https://encoding.spec.whatwg.org/#dom-textencoder-encodeinto Closes rustwasm#1172
- Loading branch information
1 parent
de85d99
commit 745b16e
Showing
4 changed files
with
110 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters