diff options
Diffstat (limited to 'ext/web/08_text_encoding.js')
-rw-r--r-- | ext/web/08_text_encoding.js | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/ext/web/08_text_encoding.js b/ext/web/08_text_encoding.js index e563c8bd4..5d41e4cd9 100644 --- a/ext/web/08_text_encoding.js +++ b/ext/web/08_text_encoding.js @@ -10,9 +10,19 @@ /// <reference lib="esnext" /> import { core, primordials } from "ext:core/mod.js"; -const ops = core.ops; -import * as webidl from "ext:deno_webidl/00_webidl.js"; -import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; +const { + isDataView, + isSharedArrayBuffer, + isTypedArray, +} = core; +const { + op_encoding_decode, + op_encoding_decode_single, + op_encoding_decode_utf8, + op_encoding_encode_into, + op_encoding_new_decoder, + op_encoding_normalize_label, +} = core.ensureFastOps(); const { DataViewPrototypeGetBuffer, DataViewPrototypeGetByteLength, @@ -32,11 +42,9 @@ const { Uint32Array, Uint8Array, } = primordials; -const { - isDataView, - isSharedArrayBuffer, - isTypedArray, -} = core; + +import * as webidl from "ext:deno_webidl/00_webidl.js"; +import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; class TextDecoder { /** @type {string} */ @@ -63,7 +71,7 @@ class TextDecoder { prefix, "Argument 2", ); - const encoding = ops.op_encoding_normalize_label(label); + const encoding = op_encoding_normalize_label(label); this.#encoding = encoding; this.#fatal = options.fatal; this.#ignoreBOM = options.ignoreBOM; @@ -154,10 +162,10 @@ class TextDecoder { if (!stream && this.#rid === null) { // Fast path for utf8 single pass encoding. if (this.#utf8SinglePass) { - return ops.op_encoding_decode_utf8(input, this.#ignoreBOM); + return op_encoding_decode_utf8(input, this.#ignoreBOM); } - return ops.op_encoding_decode_single( + return op_encoding_decode_single( input, this.#encoding, this.#fatal, @@ -166,13 +174,13 @@ class TextDecoder { } if (this.#rid === null) { - this.#rid = ops.op_encoding_new_decoder( + this.#rid = op_encoding_new_decoder( this.#encoding, this.#fatal, this.#ignoreBOM, ); } - return ops.op_encoding_decode(input, this.#rid, stream); + return op_encoding_decode(input, this.#rid, stream); } finally { if (!stream && this.#rid !== null) { core.close(this.#rid); @@ -246,7 +254,7 @@ class TextEncoder { allowShared: true, }, ); - ops.op_encoding_encode_into(source, destination, encodeIntoBuf); + op_encoding_encode_into(source, destination, encodeIntoBuf); return { read: encodeIntoBuf[0], written: encodeIntoBuf[1], |