diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-12-26 18:30:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-27 02:30:26 +0100 |
commit | 0efe438f7c191d8504355e03b27fe7e3055c9387 (patch) | |
tree | b96fe9a897eb6941c87a95a04520662d26c02fbe /ext/web | |
parent | e33c5eb704c22fad69876e87d9b852a4e5072a7a (diff) |
perf: remove opAsync (#21690)
`opAsync` requires a lookup by name on each async call. This is a
mechanical translation of all opAsync calls to ensureFastOps.
The `opAsync` API on Deno.core will be removed at a later time.
Diffstat (limited to 'ext/web')
-rw-r--r-- | ext/web/06_streams.js | 7 | ||||
-rw-r--r-- | ext/web/09_file.js | 7 | ||||
-rw-r--r-- | ext/web/13_message_port.js | 6 |
3 files changed, 15 insertions, 5 deletions
diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js index 988f1d990..31f0f2862 100644 --- a/ext/web/06_streams.js +++ b/ext/web/06_streams.js @@ -19,6 +19,11 @@ const { op_readable_stream_resource_close, op_readable_stream_resource_await_close, } = core.ensureFastOps(); +// TODO(mmastrac): use readAll +const { + op_read_all, +} = core.ensureFastOps(true); + import * as webidl from "ext:deno_webidl/00_webidl.js"; import { structuredClone } from "ext:deno_web/02_structured_clone.js"; import { @@ -1065,7 +1070,7 @@ async function readableStreamCollectIntoUint8Array(stream) { // fast path, read whole body in a single op call try { readableStreamDisturb(stream); - const promise = core.opAsync("op_read_all", resourceBacking.rid); + const promise = op_read_all(resourceBacking.rid); if (readableStreamIsUnrefable(stream)) { stream[promiseSymbol] = promise; if (stream[_isUnref]) core.unrefOpPromise(promise); diff --git a/ext/web/09_file.js b/ext/web/09_file.js index 6e91e2492..058346cfc 100644 --- a/ext/web/09_file.js +++ b/ext/web/09_file.js @@ -49,6 +49,9 @@ const { Uint8Array, } = primordials; import { createFilteredInspectProxy } from "ext:deno_console/01_console.js"; +const { + op_blob_read_part, +} = core.ensureFastOps(); // TODO(lucacasonato): this needs to not be hardcoded and instead depend on // host os. @@ -626,7 +629,7 @@ class BlobReference { * @returns {AsyncGenerator<Uint8Array>} */ async *stream() { - yield core.opAsync("op_blob_read_part", this._id); + yield op_blob_read_part(this._id); // let position = 0; // const end = this.size; @@ -634,7 +637,7 @@ class BlobReference { // const size = MathMin(end - position, 65536); // const chunk = this.slice(position, position + size); // position += chunk.size; - // yield core.opAsync("op_blob_read_part", chunk._id); + // yield op_blob_read_part( chunk._id); // } } } diff --git a/ext/web/13_message_port.js b/ext/web/13_message_port.js index 9645f5f11..c7d7d24f9 100644 --- a/ext/web/13_message_port.js +++ b/ext/web/13_message_port.js @@ -31,6 +31,9 @@ const { SymbolIterator, TypeError, } = primordials; +const { + op_message_port_recv_message, +} = core.ensureFastOps(); class MessageChannel { /** @type {MessagePort} */ @@ -147,8 +150,7 @@ class MessagePort extends EventTarget { if (this[_id] === null) break; let data; try { - data = await core.opAsync( - "op_message_port_recv_message", + data = await op_message_port_recv_message( this[_id], ); } catch (err) { |