Skip to content
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

Closed
wants to merge 2 commits into from
Closed

Conversation

ZYSzys
Copy link
Member

@ZYSzys ZYSzys commented Sep 1, 2018

Update var to const or let

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Sep 1, 2018
Copy link
Member

@apapirovski apapirovski left a 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.

@ZYSzys
Copy link
Member Author

ZYSzys commented Sep 2, 2018

I think it's more standard using const or let and === which comply with es6 features. Don't know is this change suitable in this place ? Or causing other problems ?

@@ -112,15 +112,15 @@ for (const name of Reflect.ownKeys(Dirent.prototype)) {
}

function copyObject(source) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about Object.assign ?

Copy link
Member

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

Copy link
Member

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

Copy link
Member Author

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 ?

Copy link
Member

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().

@danbev
Copy link
Contributor

danbev commented Sep 19, 2018

@danbev
Copy link
Contributor

danbev commented Sep 20, 2018

Landed in 44f7c1d.

@danbev danbev closed this Sep 20, 2018
danbev pushed a commit that referenced this pull request Sep 20, 2018
PR-URL: #22643
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
@ZYSzys ZYSzys deleted the var2let branch September 20, 2018 10:02
targos pushed a commit that referenced this pull request Sep 20, 2018
PR-URL: #22643
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Daniel Bevenius <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants