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

util: improve isInsideNodeModules #52147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Mar 18, 2024

Improve isInsideNodeModules by avoiding a Regex
kNodeModulesRE is using a non-capturing group

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Mar 18, 2024
lib/internal/util.js Outdated Show resolved Hide resolved
lib/internal/util.js Outdated Show resolved Hide resolved
lib/internal/util.js Outdated Show resolved Hide resolved
lib/internal/util.js Outdated Show resolved Hide resolved
@Uzlopak Uzlopak force-pushed the util-isInsideNodeModules branch 2 times, most recently from d08b72a to 0778337 Compare March 20, 2024 22:00
@aduh95
Copy link
Contributor

aduh95 commented Mar 20, 2024

kNodeModulesRE is using a non-capturing group

Just curious, did you do that for performance reasons, or is that a neutral change to make the regex more intention-revealing?

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

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Mar 20, 2024

I just saw that the capturing group is not used and the captured string can be very long. So i had performance in mind, but i didnt wanted to claim a (significant?) performance gain, which i probably cant prove.

@aduh95
Copy link
Contributor

aduh95 commented Mar 20, 2024

Looks like this a breaking the following tests:

  • parallel.test-buffer-constructor-outside-node-modules
  • parallel.test-buffer-constructor-node-modules-paths

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Mar 20, 2024

I will have a look at it in few hours ;)

@Uzlopak Uzlopak reopened this Mar 21, 2024
@Uzlopak
Copy link
Contributor Author

Uzlopak commented Mar 21, 2024

@aduh95

Should be fixed now.

@aduh95 aduh95 added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 21, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 21, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Apr 15, 2024

@nodejs/node-core-utils

can this be merged?

if (RegExpPrototypeExec(/^\/|\\/, filename) === null)
if (
filename[0] !== '/' &&
StringPrototypeIncludes(filename, '\\') === false
Copy link
Member

Choose a reason for hiding this comment

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

This only applies to Windows right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this PR is already old but afaik it was effecting linux too

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. needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants