Skip to content

url: improve isURL performance by adding a typecheck#52832

Closed
avivkeller wants to merge 4 commits intonodejs:mainfrom
avivkeller:patch-13
Closed

url: improve isURL performance by adding a typecheck#52832
avivkeller wants to merge 4 commits intonodejs:mainfrom
avivkeller:patch-13

Conversation

@avivkeller
Copy link
Copy Markdown
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
Copy Markdown
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
@avivkeller avivkeller added the needs-benchmark-ci PR that need a benchmark CI run. label May 4, 2024
jasnell
jasnell previously requested changes May 4, 2024
@jasnell jasnell dismissed their stale review May 4, 2024 15:18

Issue was addressed while I was leaving the comment

@aduh95
Copy link
Copy Markdown
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.

@avivkeller avivkeller closed this Aug 23, 2024
@avivkeller avivkeller deleted the patch-13 branch August 23, 2024 18:49
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.

6 participants