diff options
author | Luca Casonato <lucacasonato@yahoo.com> | 2021-06-05 23:10:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-05 23:10:07 +0200 |
commit | c73ef5fa143b473677d4cab069241ff018e0c971 (patch) | |
tree | f13f3ddb1741a81138240c36846e2a23fd562a02 /extensions/websocket/01_websocket.js | |
parent | bb0c90cadbb99784681a2acac1fd65ac7f802297 (diff) |
refactor(web): use encoding_rs for text encoding (#10844)
This commit removes all JS based text encoding / text decoding. Instead
encoding now happens in Rust via encoding_rs (already in tree). This
implementation retains stream support, but adds the last missing
encodings. We are incredibly close to 100% WPT on text encoding now.
This should reduce our baseline heap by quite a bit.
Diffstat (limited to 'extensions/websocket/01_websocket.js')
-rw-r--r-- | extensions/websocket/01_websocket.js | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/extensions/websocket/01_websocket.js b/extensions/websocket/01_websocket.js index 9fc608958..3c3e12f83 100644 --- a/extensions/websocket/01_websocket.js +++ b/extensions/websocket/01_websocket.js @@ -241,8 +241,7 @@ sendTypedArray(new DataView(data)); } else { const string = String(data); - const encoder = new TextEncoder(); - const d = encoder.encode(string); + const d = core.encode(string); this.#bufferedAmount += d.size; core.opAsync("op_ws_send", { rid: this.#rid, @@ -262,8 +261,7 @@ ); } - const encoder = new TextEncoder(); - if (reason && encoder.encode(reason).byteLength > 123) { + if (reason && core.encode(reason).byteLength > 123) { throw new DOMException( "The close reason may not be longer than 123 bytes.", "SyntaxError", |