Skip to content

path: inline conditions - #38613

Closed
VoltrexKeyva wants to merge 1 commit into
nodejs:masterfrom
VoltrexKeyva:patch-3
Closed

path: inline conditions#38613
VoltrexKeyva wants to merge 1 commit into
nodejs:masterfrom
VoltrexKeyva:patch-3

Conversation

@VoltrexKeyva

Copy link
Copy Markdown
Contributor

This condition can be inlined in the first if statement since if the path's length is 0, it'll be a empty string so we can return that as there's no need for an extra if statement.

This condition can be inlined in the first `if` statement since if the `path`'s length is 0, it'll be a empty string so we can return that as there's no need for an extra `if` statement.
@github-actionsgithub-actionsBot added needs-ci PRs that need a full CI run. path Issues and PRs related to the path subsystem. labels May 9, 2021
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@targos

Copy link
Copy Markdown
Member

Technically, it changes the behavior for edge cases like path.toNamespacedPath([]).

@VoltrexKeyva

Copy link
Copy Markdown
ContributorAuthor

Technically, it changes the behavior for edge cases like path.toNamespacedPath([]).

Passing an empty array ([]) would still return the array itself since we first check if the type of the value isn't a string -> (if type is not string or length of the value is 0, return value).
I don't see a behavior change here though.

@targos

Copy link
Copy Markdown
Member

You're right, sorry about that 🤦‍♂️

@nodejs-github-bot

nodejs-github-bot commented May 10, 2021

Copy link
Copy Markdown
Collaborator

@RaisinTenRaisinTen added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 10, 2021
@jasnelljasnell added fast-track PRs that do not need to wait for 48 hours to land. and removed needs-ci PRs that need a full CI run. labels May 10, 2021
@github-actions

Copy link
Copy Markdown
Contributor

Fast-track has been requested by @jasnell. Please 👍 to approve.

@Trott

This comment has been minimized.

@TrottTrott removed the fast-track PRs that do not need to wait for 48 hours to land. label May 12, 2021
@lpinca

Copy link
Copy Markdown
Member

@Trott what is the behavior change?

@Trott

Copy link
Copy Markdown
Member

@Trott what is the behavior change?

@lpinca I didn't want to provide an example until I compiled with the change and tested. And now that I've done that...uh...yeah, the types of things I was thinking about don't change the behavior. Uh..whoops.

@TrottTrott added the fast-track PRs that do not need to wait for 48 hours to land. label May 12, 2021
@github-actions

Copy link
Copy Markdown
Contributor

Fast-track has been requested by @Trott. Please 👍 to approve.

@jasnell

Copy link
Copy Markdown
Member

Landed in 89f592c

@jasnelljasnell closed this May 12, 2021
jasnell pushed a commit that referenced this pull request May 12, 2021
This condition can be inlined in the first `if` statement since
if the `path`'s length is 0, it'll be a empty string so we can
return that as there's no need for an extra `if` statement.
PR-URL: #38613
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@VoltrexKeyva
VoltrexKeyva deleted the patch-3 branch May 12, 2021 15:13
targos pushed a commit that referenced this pull request May 17, 2021
This condition can be inlined in the first `if` statement since
if the `path`'s length is 0, it'll be a empty string so we can
return that as there's no need for an extra `if` statement.
PR-URL: #38613
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@targostargos mentioned this pull request May 18, 2021
targos pushed a commit that referenced this pull request May 30, 2021
This condition can be inlined in the first `if` statement since
if the `path`'s length is 0, it'll be a empty string so we can
return that as there's no need for an extra `if` statement.
PR-URL: #38613
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
targos pushed a commit that referenced this pull request Jun 5, 2021
This condition can be inlined in the first `if` statement since
if the `path`'s length is 0, it'll be a empty string so we can
return that as there's no need for an extra `if` statement.
PR-URL: #38613
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
targos pushed a commit that referenced this pull request Jun 5, 2021
This condition can be inlined in the first `if` statement since
if the `path`'s length is 0, it'll be a empty string so we can
return that as there's no need for an extra `if` statement.
PR-URL: #38613
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@targostargos mentioned this pull request Jun 6, 2021
targos pushed a commit that referenced this pull request Jun 11, 2021
This condition can be inlined in the first `if` statement since
if the `path`'s length is 0, it'll be a empty string so we can
return that as there's no need for an extra `if` statement.
PR-URL: #38613
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.fast-trackPRs that do not need to wait for 48 hours to land.pathIssues and PRs related to the path subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants

@VoltrexKeyva@nodejs-github-bot@targos@Trott@lpinca@jasnell@cjihrig@richardlau@marsonya@RaisinTen