1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00
denoland-deno/ext/fetch
Marcos Casagrande 65a94a6176
perf(ext/fetch): use new instead of createBranded (#20624)
This PR optimizes `fromInner*` methods of `Request` / `Header` /
`Response` used by `Deno.serve` and `fetch` by using `new` instead of
`ObjectCreate` from `createBranded`.

The "brand" is created by passing `webidl.brand` to the constructor
instead.


142449ecab/ext/webidl/00_webidl.js (L1001-L1005)

### Benchmark
```js
const createBranded = Symbol("create branded");
const brand = Symbol("brand");
class B {
  constructor(init) {
    if (init === createBranded) {
      this[brand] = brand;
    }
  }
}

Deno.bench("Object.create(protoype)", () => {
  Object.create(B.prototype);
});

Deno.bench("new Class", () => {
  new B(createBranded);
});
```

```
cpu: 13th Gen Intel(R) Core(TM) i9-13900H
runtime: deno 1.37.0 (x86_64-unknown-linux-gnu)

benchmark                    time (avg)        iter/s             (min … max)       p75       p99      p995
----------------------------------------------------------------------------- -----------------------------
Object.create(protoype)       8.74 ns/iter 114,363,610.3    (7.32 ns … 26.02 ns)   8.65 ns  13.39 ns  14.47 ns
new Class                     3.05 ns/iter 328,271,012.2      (2.78 ns … 9.1 ns)   3.06 ns   3.46 ns    3.5 ns
```
2023-09-21 20:06:42 -06:00
..
20_headers.js perf(ext/fetch): use new instead of createBranded (#20624) 2023-09-21 20:06:42 -06:00
21_formdata.js chore: update deno_lint to 0.46.0 (#19372) 2023-06-05 15:57:01 -04:00
22_body.js fix(ext/fetch): clone second branch chunks in Body.clone() (#20057) 2023-08-15 09:21:02 +02:00
22_http_client.js refactor: Use ES modules for internal runtime code (#17648) 2023-02-07 20:22:46 +01:00
23_request.js perf(ext/fetch): use new instead of createBranded (#20624) 2023-09-21 20:06:42 -06:00
23_response.js perf(ext/fetch): use new instead of createBranded (#20624) 2023-09-21 20:06:42 -06:00
26_fetch.js perf: improve async op santizer speed and accuracy (#20501) 2023-09-16 07:48:31 +02:00
Cargo.toml 1.37.0 (#20574) 2023-09-19 20:29:17 +00:00
fs_fetch_handler.rs refactor(ext/fetch): Remove FetchRequestBodyResource from FetchHandler interface (#20100) 2023-08-09 10:47:47 -06:00
internal.d.ts refactor: remove remaining references to "flash" server (#18580) 2023-04-04 12:37:56 +02:00
lib.deno_fetch.d.ts fix(dts): make globals available on globalThis (#19438) 2023-07-03 14:36:55 -04:00
lib.rs refactor: rewrite some ops to op2 macro (#20603) 2023-09-21 08:08:23 -06:00
README.md Rename extensions/ directory to ext/ (#11643) 2021-08-11 12:27:05 +02:00

deno_fetch

This crate implements the Fetch API.

Spec: https://fetch.spec.whatwg.org/