Skip to content

esm: avoid accessing lazy getters for urls - #47542

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
anonrig:esm-improve-protocol
Apr 15, 2023
Merged

esm: avoid accessing lazy getters for urls#47542
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
anonrig:esm-improve-protocol

Conversation

@anonrig

Copy link
Copy Markdown
Member

This pull request avoids multiple calls to the protocol getter of the URL. Previor to Ada version 2, url.protocol was always returned an already allocated string, but right now, it slices a new string for each call. Storing it in a variable and access it, would make some improvement in terms of performance.

cc @nodejs/url

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/modules

@nodejs-github-botnodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels Apr 13, 2023
@anonrig
anonrigforce-pushed the esm-improve-protocol branch from bb4b123 to 8661421CompareApril 13, 2023 14:50
@anonriganonrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Apr 13, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 13, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@lemire

Copy link
Copy Markdown
Member

And I guess that we don’t expose the protocole type as an integer to JavaScript? If we did, we could avoid string comparisons.

@anonrig

Copy link
Copy Markdown
MemberAuthor

And I guess that we don’t expose the protocole type as an integer to JavaScript? If we did, we could avoid string comparisons.

That's a really good argument @lemire. I'll look for some alternatives after this pull request, to improve it even more.

@lemire

Copy link
Copy Markdown
Member

I would expect that if you have several instances of the protocol string in JavaScript, that would be a performance penalty irrespective of the backend. Having just one reference is better.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@anonriganonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 13, 2023
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 15, 2023
@nodejs-github-bot
nodejs-github-bot merged commit 93e550a into nodejs:mainApr 15, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 93e550a

targos pushed a commit that referenced this pull request May 2, 2023
PR-URL: #47542
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@targostargos mentioned this pull request May 2, 2023
danielleadams pushed a commit that referenced this pull request Jul 6, 2023
PR-URL: #47542
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
MoLow pushed a commit to MoLow/node that referenced this pull request Jul 6, 2023
PR-URL: nodejs#47542
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.esmIssues and PRs related to the ECMAScript Modules implementation.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@anonrig@nodejs-github-bot@lemire@ljharb@Qard@lpinca@JakobJingleheimer@aduh95