-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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
[Refactor] Use "case" instead of multi "if" #1332
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't case
slower than multiple if
s?
"_sunos") | ||
NVM_CPU_CORES="$(psrinfo | wc -l)";; | ||
"_aix") | ||
NVM_CPU_CORES="$(lsconf | command grep 'Number Of Processors:'| command awk '{print $4}')";; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the contents of the case are not on the same line as the )
, then the closing ;;
should be on a line by itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, thanks.
09cedfa
to
673c682
Compare
NVM_CPU_CORES="$(psrinfo | wc -l)" | ||
;; | ||
"_aix") | ||
NVM_CPU_CORES="$(lsconf | command grep 'Number Of Processors:'| command awk '{print $4}')" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heads up, this is going to conflict with #1319 which is being merged shortly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we both can update this part immediately, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's merged; feel free to rebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
673c682
to
fb230b2
Compare
@PeterDaveHello what about my question above? |
@ljharb oops, is there any reference about the difference? I wonder if it's that significant that we should worry about it, use so many if/else may not be a good implement, and also, I want to add one more OS type in |
Why would we want to disable the binary install for alpine linux? |
Just like: |
Not all of them, but a good percentage, yes - at least, that's what I'm advocating for. |
Then that's the part once they provided the binary for Alpine, before that, the behavior should be like FreeBSD, but no matter which one, I think we don't need to bundle with this PR, not the same issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't performance-critical code, so I'm OK with using the case here.
This can also help us use the more flexible pattern matching in "case" in future.