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

src: simplify legacy resolve functionality #48648

Closed
wants to merge 3 commits into from

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Jul 3, 2023

Changes and their reasonings:

  • Added DCHECK_NOT_NULL to avoid passing nullptr
  • Replaced env->isolate()->ThrowException with their respective MACROs THROW_ERR_INVALID_URL_SCHEME etc.
  • Removed the usage of NOLINT and used pointers to conform the cpp contributing guidelines.
  • Reduced the number of branches/if statements in for loops to improve performance
  • Added fast paths for percent character findings to avoid unnecessary iterations
  • Moved legacy_main_extensions to header file for readability purposes, made it constexpr to evaluate it in the compile time.
  • Removed unnecessary url->get_pathname() calls which are more costly than url->has_empty_hostname()

cc @H4ad

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Jul 3, 2023
src/node_file.cc Show resolved Hide resolved
@anonrig anonrig force-pushed the refactor-legacy-resolve branch 6 times, most recently from 13c8363 to d3cb3e1 Compare July 4, 2023 02:24
src/node_file.cc Outdated Show resolved Hide resolved
@anonrig anonrig requested a review from RaisinTen July 4, 2023 21:27
@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 5, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 5, 2023
@nodejs-github-bot
Copy link
Collaborator

@RaisinTen
Copy link
Contributor

@anonrig since this change is a list of general improvements, what do you think about briefly describing the changes in the description and the reasoning behind those? For example:

  • DCHECK_NOT_NULL additions to avoid passing nullptrs where nullptrs are not expected
  • env->isolate()->ThrowException(ERR_INVALID_URL_SCHEME(env->isolate())); -> THROW_ERR_INVALID_URL_SCHEME(env) because ...
  • etc.?

I think that would make it easier to review this PR because that way I would know what to expect and then check the diff instead of inferring things from the diff directly.

@anonrig
Copy link
Member Author

anonrig commented Jul 6, 2023

@RaisinTen you're absolutely right. I updated the pull request description. Appreciate your feedback.

@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig requested a review from aduh95 July 6, 2023 20:49
@anonrig
Copy link
Member Author

anonrig commented Jul 6, 2023

cc @nodejs/loaders @nodejs/modules

src/node_file.cc Show resolved Hide resolved
src/node_file.cc Outdated Show resolved Hide resolved
src/node_file.cc Outdated Show resolved Hide resolved
src/node_file.cc Outdated Show resolved Hide resolved
@anonrig anonrig requested a review from RaisinTen July 9, 2023 03:10
@anonrig anonrig added the review wanted PRs that need reviews. label Jul 9, 2023
@anonrig
Copy link
Member Author

anonrig commented Jul 9, 2023

cc @nodejs/cpp-reviewers

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

Copy link
Contributor

@RaisinTen RaisinTen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

THROW_ERR_INVALID_FILE_URL_HOST(
env,
"File URL host must be \"localhost\" or empty on %s",
std::string(per_process::metadata.platform));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the std::string() part needed here?

Suggested change
std::string(per_process::metadata.platform));
per_process::metadata.platform);

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig closed this Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. review wanted PRs that need reviews.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants