summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-12-26 18:30:26 -0700
committerGitHub <noreply@github.com>2023-12-27 02:30:26 +0100
commit0efe438f7c191d8504355e03b27fe7e3055c9387 (patch)
treeb96fe9a897eb6941c87a95a04520662d26c02fbe /cli
parente33c5eb704c22fad69876e87d9b852a4e5072a7a (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 'cli')
-rw-r--r--cli/bench/http/deno_http_ops.js43
-rw-r--r--cli/tests/unit/cron_test.ts7
2 files changed, 5 insertions, 45 deletions
diff --git a/cli/bench/http/deno_http_ops.js b/cli/bench/http/deno_http_ops.js
deleted file mode 100644
index 216a47905..000000000
--- a/cli/bench/http/deno_http_ops.js
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-
-const addr = Deno.args[0] || "127.0.0.1:4500";
-const [hostname, port] = addr.split(":");
-const tcp = Deno.listen({ hostname, port: Number(port) });
-console.log("Server listening on", addr);
-
-class Http {
- id;
- constructor(id) {
- this.id = id;
- }
- [Symbol.asyncIterator]() {
- return {
- next: async () => {
- const reqEvt = await Deno[Deno.internal].core.opAsync(
- "op_http_accept",
- this.id,
- );
- return { value: reqEvt ?? undefined, done: reqEvt === null };
- },
- };
- }
-}
-
-for await (const conn of tcp) {
- const id = Deno[Deno.internal].core.ops.op_http_start(conn.rid);
- const http = new Http(id);
- (async () => {
- for await (const req of http) {
- if (req == null) continue;
- const { 0: stream } = req;
- await Deno[Deno.internal].core.opAsync(
- "op_http_write_headers",
- stream,
- 200,
- [],
- "Hello World",
- );
- Deno[Deno.internal].core.close(stream);
- }
- })();
-}
diff --git a/cli/tests/unit/cron_test.ts b/cli/tests/unit/cron_test.ts
index 2a146bcfa..8c484af32 100644
--- a/cli/tests/unit/cron_test.ts
+++ b/cli/tests/unit/cron_test.ts
@@ -1,9 +1,12 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { assertEquals, assertThrows } from "./test_util.ts";
-import {
+
+// @ts-ignore This is not publicly typed namespace, but it's there for sure.
+const {
formatToCronSchedule,
parseScheduleToString,
-} from "../../../ext/cron/01_cron.ts";
+ // @ts-expect-error TypeScript (as of 3.7) does not support indexing namespaces by symbol
+} = Deno[Deno.internal];
const sleep = (time: number) => new Promise((r) => setTimeout(r, time));