Skip to content

Commit

Permalink
perf(ext/url): use DOMString instead of USVString as webidl converter…
Browse files Browse the repository at this point in the history
… for URL parsing (#11775)

A 20% decrease in url parsing:
- before: `~2450ns/parse`
- after: `~1950ns/parse`
  • Loading branch information
AaronO authored Aug 19, 2021
1 parent bfc197f commit 9105104
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions ext/url/00_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
Expand Down Expand Up @@ -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",
});
Expand All @@ -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",
});
Expand All @@ -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",
});
Expand All @@ -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",
});
Expand All @@ -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",
});
Expand All @@ -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",
});
Expand All @@ -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",
});
Expand All @@ -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",
});
Expand All @@ -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",
});
Expand All @@ -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",
});
Expand Down

0 comments on commit 9105104

Please sign in to comment.