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

url: simplify and improve url formatting #46736

Merged
merged 1 commit into from
Feb 24, 2023

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Feb 19, 2023

This pull request separates the logic of kFormat and URL and moves the logic to C++.

Quick summary:

  • Move Url.format implementation to C++ where it directly calls Ada. This is done to avoid having any URL logic inside Node.js
  • Call search setter whenever searchParams is changed, instead of calculating href on the JS layer. This was done to remove any URL logic inside Node.js.
  • Remove kFormat since it isn't used anymore after step 1 and 2.
  • Remove hasOpaquePath and hasHost from URL, since it was only needed for kFormat and searchParams setter.
  • Ise ToStringView() and ToString() methods that @addaleax recommended.

cc @nodejs/url @nodejs/cpp-reviewers

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. url Issues and PRs related to the legacy built-in url module. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels Feb 19, 2023
@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 19, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 19, 2023
@nodejs-github-bot
Copy link
Collaborator

src/node_url.cc Outdated Show resolved Hide resolved
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@RaisinTen
Copy link
Contributor

Is this for better performance?

@anonrig
Copy link
Member Author

anonrig commented Feb 20, 2023

Is this for better performance?

Not for this specifically, but I'm preparing for the new Ada changes where we will focus on enabling node.js-specific APIs to improve the performance. This is mainly for removing the URL parsing logic from Node.js core, and moving it to C++/Ada.

@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 20, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 20, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

lib/url.js Outdated Show resolved Hide resolved
@anonrig anonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 24, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 24, 2023
@nodejs-github-bot nodejs-github-bot merged commit 8073392 into nodejs:main Feb 24, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in 8073392

@anonrig anonrig deleted the improve-url-parsing branch February 24, 2023 22:35
targos pushed a commit that referenced this pull request Mar 13, 2023
PR-URL: #46736
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@danielleadams
Copy link
Contributor

@anonrig this broke the build when landing in v18.x. Do you mind creating a backport PR?

@danielleadams danielleadams added the backport-requested-v18.x PRs awaiting manual backport to the v18.x-staging branch. label Apr 3, 2023
anonrig added a commit to anonrig/node that referenced this pull request Apr 5, 2023
PR-URL: nodejs#46736
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@anonrig anonrig added backport-open-v18.x Indicate that the PR has an open backport. and removed backport-requested-v18.x PRs awaiting manual backport to the v18.x-staging branch. labels Apr 5, 2023
@anonrig
Copy link
Member Author

anonrig commented Apr 5, 2023

This depends on #46723

@anonrig anonrig added backport-requested-v18.x PRs awaiting manual backport to the v18.x-staging branch. and removed backport-open-v18.x Indicate that the PR has an open backport. labels Apr 5, 2023
anonrig added a commit to anonrig/node that referenced this pull request Apr 6, 2023
PR-URL: nodejs#46736
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@anonrig anonrig added backport-open-v18.x Indicate that the PR has an open backport. and removed backport-requested-v18.x PRs awaiting manual backport to the v18.x-staging branch. labels Apr 6, 2023
anonrig added a commit to anonrig/node that referenced this pull request Apr 11, 2023
PR-URL: nodejs#46736
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
anonrig added a commit to anonrig/node that referenced this pull request Apr 11, 2023
PR-URL: nodejs#46736
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
danielleadams pushed a commit that referenced this pull request Apr 12, 2023
PR-URL: #46736
Backport-PR-URL: #47435
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@danielleadams danielleadams added backported-to-v18.x PRs backported to the v18.x-staging branch. and removed backport-open-v18.x Indicate that the PR has an open backport. labels Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported-to-v18.x PRs backported to the v18.x-staging branch. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. review wanted PRs that need reviews. url Issues and PRs related to the legacy built-in url module. whatwg-url Issues and PRs related to the WHATWG URL implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants