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: improve isURL performance by adding a typecheck #52832

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

RedYetiDev
Copy link
Member

This PR makes the isURL function first verify that the input (self) is an object. This should make the benchmarking time much faster for non-urls, as shown in #52672

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/url

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels May 4, 2024
@RedYetiDev RedYetiDev added the needs-benchmark-ci PR that need a benchmark CI run. label May 4, 2024
lib/internal/url.js Outdated Show resolved Hide resolved
jasnell
jasnell previously requested changes May 4, 2024
lib/internal/url.js Outdated Show resolved Hide resolved
@jasnell jasnell dismissed their stale review May 4, 2024 15:18

Issue was addressed while I was leaving the comment

@aduh95
Copy link
Contributor

aduh95 commented May 4, 2024

I think the commit message is wrong (likely adding one check will decrease performance rather than improve it, but in any case it's likely not measurable anyway). I suppose adding this check would help avoid having non-object being accepted as URLs (if someone mutates enough built-in prototypes, literals could be detected as URLs by this util), but if that's a use-case we want to support, we should have a test for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-benchmark-ci PR that need a benchmark CI run. needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants