-
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
lib: refactor variable declarations #22643
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.
Hi @ZYSzys! As you'll note by the number of places that still use var
, we tend to avoid changing these for the sake of it unless the surrounding code is being refactored. Changes like this make it more difficult to use git blame
efficiently.
I think it's more standard using |
@@ -112,15 +112,15 @@ for (const name of Reflect.ownKeys(Dirent.prototype)) { | |||
} | |||
|
|||
function copyObject(source) { |
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.
What about Object.assign ?
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.
We’d probably want to benchmark that first
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 not likely to be much slower than for-in
to be honest. /cc @bmeurer
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.
Is this even a bit faster ?
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.
Recent versions of V8 should have fast Object.assign()
.
Landed in 44f7c1d. |
PR-URL: #22643 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
PR-URL: #22643 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Update
var
toconst
orlet
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes