1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-25 00:29:09 -05:00

perf(ext/fetch): skip USVString webidl conv on string constructor (#12168)

* perf(ext/fetch): skip USVString webidl conv on string constructor
* Rename webidl convert to RequestInfo_DOMString

To disambiguate and hint that it normalizes to DOMString instead of USVString since DOMString => USVString is handled by `op_url_parse` when calling `new URL(...)`
This commit is contained in:
Aaron O'Mullan 2021-09-23 11:40:58 +02:00 committed by GitHub
parent 830586d242
commit e0c858fa27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -220,7 +220,7 @@
constructor(input, init = {}) { constructor(input, init = {}) {
const prefix = "Failed to construct 'Request'"; const prefix = "Failed to construct 'Request'";
webidl.requiredArguments(arguments.length, 1, { prefix }); webidl.requiredArguments(arguments.length, 1, { prefix });
input = webidl.converters["RequestInfo"](input, { input = webidl.converters["RequestInfo_DOMString"](input, {
prefix, prefix,
context: "Argument 1", context: "Argument 1",
}); });
@ -424,14 +424,15 @@
"Request", "Request",
Request, Request,
); );
webidl.converters["RequestInfo"] = (V, opts) => { webidl.converters["RequestInfo_DOMString"] = (V, opts) => {
// Union for (Request or USVString) // Union for (Request or USVString)
if (typeof V == "object") { if (typeof V == "object") {
if (V instanceof Request) { if (V instanceof Request) {
return webidl.converters["Request"](V, opts); return webidl.converters["Request"](V, opts);
} }
} }
return webidl.converters["USVString"](V, opts); // Passed to new URL(...) which implictly converts DOMString -> USVString
return webidl.converters["DOMString"](V, opts);
}; };
webidl.converters["RequestRedirect"] = webidl.createEnumConverter( webidl.converters["RequestRedirect"] = webidl.createEnumConverter(
"RequestRedirect", "RequestRedirect",