-
Notifications
You must be signed in to change notification settings - Fork 29.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
Minor improvements #8906
Minor improvements #8906
Conversation
Change '==' to '===' Change 'var' to 'let' Delete unused argument in function
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 would be curious if any of the other changes have performance effects.
@@ -182,7 +182,7 @@ | |||
process._setupProcessObject(pushValueToArray); | |||
|
|||
function pushValueToArray() { | |||
for (var i = 0; i < arguments.length; i++) | |||
for (let i = 0; i < arguments.length; i++) |
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 is used via a few c++ functions to improve the performance of pushing onto an array. I'm pretty sure let
is still a bit slower than var
, so I would probably leave this one alone
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 agree.
@@ -443,7 +443,7 @@ | |||
if (EXPOSE_INTERNALS) { | |||
NativeModule.nonInternalExists = NativeModule.exists; | |||
|
|||
NativeModule.isInternal = function(id) { |
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 is best left unchanged since the other isInternal()
implementation does use id
and we won't know which is being used at runtime. IIRC V8 still prefers it (performance-wise) when the argument/parameter counts match.
I know others have said otherwise about being able to use |
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.
- The
==
->===
changes seem good to me. - The
var
->let
changes are problematic, especially the ones involvingfor
loops. Currently, V8 performance oflet
in loops is often not great. Unless you are prepared to benchmark the changes somehow, I'd stick withvar
instead. - I'd also leave the
id
argument in theisInternal()
function for the performance/optimization reasons described by @mscdex.
If the let
and function argument changes were happening in code in the test
directory rather than the lib/internal
directory, I'd be inclined to give them a thumbs up. But here, we have to be a bit more wary of things that might negatively impact performance.
Change '==' to '==='
I humbly incline and apply the changes requested, gentlemen. 😉 |
LGTM if CI is ok with it: https://ci.nodejs.org/job/node-test-pull-request/4374/ |
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
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
Bit too much red in that last run... trying again: https://ci.nodejs.org/job/node-test-pull-request/4411/ |
Change '==' to '===' PR-URL: #8906 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Change '==' to '===' PR-URL: #8906 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Change '==' to '===' PR-URL: #8906 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net>
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
Description of change
Change '==' to '==='
Change 'var' to 'let'
Delete unused argument in function