-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
lib: remove unnecessary symbols #22455
Conversation
lib/_stream_readable.js
Outdated
@@ -325,7 +325,7 @@ Readable.prototype.setEncoding = function(enc) { | |||
// Don't raise the hwm > 8MB | |||
const MAX_HWM = 0x800000; | |||
function computeNewHighWaterMark(n) { | |||
if (n >= MAX_HWM) { | |||
if (n > MAX_HWM) { |
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 change causes the else
branch to be taken when n
is equal to MAX_HWM
. That seems less efficient then the if
branch. and possibly a bug?
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.
OK, Thanks I've removed that modification.
Remove `(...)`, because this is a simple,sensitive expression.
This appears to be the sort of stylistic changes being discussed in #22351. |
@richardlau:But you have to admit that this Please compare with them:
So sometimes for those useless styles or styles aren't necessary (But not change to a style that will make bad effects on what the codes were). I think it worth changing to make tiny (but not much) refactors. Hope you can understand what I mean here. |
I am -0.5 on this. There might be a eslint rule for this and it would be fine for me with a rule if that does not result in to much churn. |
FWIW I generally prefer including conditional statements like this in parentheses when being assigned as a value as it makes it easier to read and that's why these parentheses currently exist there. |
I think it's time to have a disscussion on when to refactor(IMO): First, as what I said above, refactoring codes cannot make bad effects on what the codes were (including making performance lower than before, making hard to read / understand, or making unit tests too complicated to complete……ect). Anyway, any bad effects resulted by refactoring will be abandoned. And what @richardlau's closed example just belongs to this (because using Second, to make codes in style union. I mostly agree with what @BridgeAR said, but I have to say that even if when we all pass the eslint's checks, sometimes the stylish still will have useless or unnecessary things to be removed (Just like this fixture above). And the reason why we will do refactoring is that we should clean up codes to make them in union and look better, and obviously our Nodejs project belongs to the developers all over the world. Since we cannot control different people's options of code style, why don't we make them in union for obviously stylish problems? :) As for @mscdex's suggestions, this is still in discussion. If most of you think for a condition wrapped by Line 78 in 6acb550
(……) ).
|
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 larger patches are much more relevant when talking about “churn”. A +1/-1 change is not getting in the way of anything – if it can be backported, great, if it can’t, it doesn’t make anything worse either in terms of merge conflicts.
@addaleax:Yes I agree with you. And I think for those rules we should refactor codes:
Any other better ideas in details? It's interesting to share ideas and experience with all of you here :D |
CI: https://ci.nodejs.org/job/node-test-pull-request/16804/ I’d prefer to land this in the next few days rather than having it hang in limbo, given that there are 8 approving reviews at this point. |
Resume build: https://ci.nodejs.org/job/node-test-pull-request/16920/ |
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.
LGTM
Maybe this can be merged? |
CI was stopped, resuming again... https://ci.nodejs.org/job/node-test-pull-request/17149/ |
Only red CI was arm-fanned. Re-run: https://ci.nodejs.org/job/node-test-commit-arm-fanned/3457/ |
Landed in 9c6f59e 😄 |
Remove `(...)`, because this is a simple,sensitive expression. PR-URL: #22455 Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Thanks all for your help! |
Remove `(...)`, because this is a simple,sensitive expression. PR-URL: #22455 Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Remove `(...)`, because this is a simple,sensitive expression. PR-URL: #22455 Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Remove `(...)`, because this is a simple,sensitive expression. PR-URL: #22455 Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Remove
(...)
, because this is a simple,sensitive expression.make -j4 test
(UNIX), orvcbuild test
(Windows) passes