1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-11 08:33:43 -05:00

perf(ext/url): use DOMString instead of USVString as webidl converter for URL parsing (#11775)

A 20% decrease in url parsing:
- before: `~2450ns/parse`
- after: `~1950ns/parse`
This commit is contained in:
Aaron O'Mullan 2021-08-19 17:36:14 +02:00 committed by GitHub
parent bfc197f33e
commit 91051047cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -313,9 +313,9 @@
*/
constructor(url, base = undefined) {
const prefix = "Failed to construct 'URL'";
url = webidl.converters.USVString(url, { prefix, context: "Argument 1" });
url = webidl.converters.DOMString(url, { prefix, context: "Argument 1" });
if (base !== undefined) {
base = webidl.converters.USVString(base, {
base = webidl.converters.DOMString(base, {
prefix,
context: "Argument 2",
});
@ -363,7 +363,7 @@
webidl.assertBranded(this, URL);
const prefix = "Failed to set 'hash' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix });
value = webidl.converters.USVString(value, {
value = webidl.converters.DOMString(value, {
prefix,
context: "Argument 1",
});
@ -385,7 +385,7 @@
webidl.assertBranded(this, URL);
const prefix = "Failed to set 'host' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix });
value = webidl.converters.USVString(value, {
value = webidl.converters.DOMString(value, {
prefix,
context: "Argument 1",
});
@ -407,7 +407,7 @@
webidl.assertBranded(this, URL);
const prefix = "Failed to set 'hostname' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix });
value = webidl.converters.USVString(value, {
value = webidl.converters.DOMString(value, {
prefix,
context: "Argument 1",
});
@ -429,7 +429,7 @@
webidl.assertBranded(this, URL);
const prefix = "Failed to set 'href' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix });
value = webidl.converters.USVString(value, {
value = webidl.converters.DOMString(value, {
prefix,
context: "Argument 1",
});
@ -454,7 +454,7 @@
webidl.assertBranded(this, URL);
const prefix = "Failed to set 'password' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix });
value = webidl.converters.USVString(value, {
value = webidl.converters.DOMString(value, {
prefix,
context: "Argument 1",
});
@ -476,7 +476,7 @@
webidl.assertBranded(this, URL);
const prefix = "Failed to set 'pathname' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix });
value = webidl.converters.USVString(value, {
value = webidl.converters.DOMString(value, {
prefix,
context: "Argument 1",
});
@ -498,7 +498,7 @@
webidl.assertBranded(this, URL);
const prefix = "Failed to set 'port' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix });
value = webidl.converters.USVString(value, {
value = webidl.converters.DOMString(value, {
prefix,
context: "Argument 1",
});
@ -520,7 +520,7 @@
webidl.assertBranded(this, URL);
const prefix = "Failed to set 'protocol' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix });
value = webidl.converters.USVString(value, {
value = webidl.converters.DOMString(value, {
prefix,
context: "Argument 1",
});
@ -542,7 +542,7 @@
webidl.assertBranded(this, URL);
const prefix = "Failed to set 'search' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix });
value = webidl.converters.USVString(value, {
value = webidl.converters.DOMString(value, {
prefix,
context: "Argument 1",
});
@ -565,7 +565,7 @@
webidl.assertBranded(this, URL);
const prefix = "Failed to set 'username' on 'URL'";
webidl.requiredArguments(arguments.length, 1, { prefix });
value = webidl.converters.USVString(value, {
value = webidl.converters.DOMString(value, {
prefix,
context: "Argument 1",
});