From c73ef5fa143b473677d4cab069241ff018e0c971 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Sat, 5 Jun 2021 23:10:07 +0200 Subject: 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. --- extensions/file/02_filereader.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'extensions/file/02_filereader.js') diff --git a/extensions/file/02_filereader.js b/extensions/file/02_filereader.js index 428d8fd54..c7ca3d980 100644 --- a/extensions/file/02_filereader.js +++ b/extensions/file/02_filereader.js @@ -14,9 +14,9 @@ ((window) => { const webidl = window.__bootstrap.webidl; - const { decode } = window.__bootstrap.encoding; + const { forgivingBase64Encode } = window.__bootstrap.infra; + const { decode, TextDecoder } = window.__bootstrap.encoding; const { parseMimeType } = window.__bootstrap.mimesniff; - const base64 = window.__bootstrap.base64; const state = Symbol("[[state]]"); const result = Symbol("[[result]]"); @@ -168,7 +168,7 @@ case "DataUrl": { const mediaType = blob.type || "application/octet-stream"; this[result] = `data:${mediaType};base64,${ - base64.fromByteArray(bytes) + forgivingBase64Encode(bytes) }`; break; } -- cgit v1.2.3