forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(op_crates/web): rewrite TextEncoder.encodeInto
TextEncoder.encodeInto main advantage vs TextEncoder.encode is that it more efficient by lowering pressure on memory allocator. The current implementation was doing a lot of allocations under the hood: - UTF8Encoder is instantiated. - UTF8Encoder allocates arrays as the return value - The string is essentially duplicated by the stringToCodePoints function and then wrapped into a Stream. The implementation also failed some wpt tests (denoland#9006). To fix all of these issues, reimplement UTF-8 encoding in a function that 0 allocations and receives offset states from the caller, while also correctly handling boundaries of the input buffer.
- Loading branch information
Showing
2 changed files
with
130 additions
and
42 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