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 /runtime/js/40_read_file.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 'runtime/js/40_read_file.js')
-rw-r--r-- | runtime/js/40_read_file.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/runtime/js/40_read_file.js b/runtime/js/40_read_file.js index 1efd5338d..7eee28d89 100644 --- a/runtime/js/40_read_file.js +++ b/runtime/js/40_read_file.js @@ -2,6 +2,7 @@ "use strict"; ((window) => { + const core = window.Deno.core; const { open, openSync } = window.__bootstrap.files; const { readAll, readAllSync } = window.__bootstrap.io; @@ -29,8 +30,7 @@ const file = openSync(path); try { const contents = readAllSync(file); - const decoder = new TextDecoder(); - return decoder.decode(contents); + return core.decode(contents); } finally { file.close(); } @@ -40,8 +40,7 @@ const file = await open(path); try { const contents = await readAll(file); - const decoder = new TextDecoder(); - return decoder.decode(contents); + return core.decode(contents); } finally { file.close(); } |