Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esm: avoid accessing lazy getters for urls #47542

Merged
merged 1 commit into from
Apr 15, 2023

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Apr 13, 2023

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
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/modules

@nodejs-github-bot nodejs-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 anonrig 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-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 13, 2023
@nodejs-github-bot
Copy link
Collaborator

@lemire
Copy link
Member

lemire commented Apr 13, 2023

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
Member Author

anonrig commented Apr 13, 2023

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
Member

lemire commented Apr 13, 2023

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
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 13, 2023
@nodejs-github-bot nodejs-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:main Apr 15, 2023
30 checks passed
@nodejs-github-bot
Copy link
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>
@targos targos 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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants