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

fs: define constants with const #522

Closed
wants to merge 1 commit into from
Closed

fs: define constants with const #522

wants to merge 1 commit into from

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Jan 20, 2015

Define fs constants using const. In the tests that I've done, it appears that v8 is able to optimize const. Suggesting this as an alternative to #507. If this is acceptable, I'd be interested in updating other constants throughout the JS codebase.

Define fs constants using const, as the newer version of
v8 supports it, and appears to be capable of optimizing.
@targos
Copy link
Member

targos commented Jan 20, 2015

This is not really an alternative to #507, more like an addition. The fact that constants are defined in fs.js does not make the properties of the exports object unwritable.

@bnoordhuis
Copy link
Member

LGTM and it could even be less conservative IMO. V8 used to have trouble optimizing let/const-scoped bindings sometimes but I did a quick check of the source code and it looks like that has been resolved.

cjihrig added a commit that referenced this pull request Jan 20, 2015
Define fs constants using const, as the newer version of
v8 supports it, and appears to be capable of optimizing.

PR-URL: #522
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@cjihrig
Copy link
Contributor Author

cjihrig commented Jan 20, 2015

Landed in 86eda17. @bnoordhuis I wasn't sure if const would be accepted or not. I'll be a little more aggressive updating the other code.

@cjihrig cjihrig closed this Jan 20, 2015
@cjihrig cjihrig deleted the fs-consts branch January 20, 2015 17:30
@cjihrig
Copy link
Contributor Author

cjihrig commented Jan 20, 2015

And @targos, thanks I didn't account for the exports.

@cjihrig
Copy link
Contributor Author

cjihrig commented Jan 20, 2015

@bnoordhuis what's your opinion on setting modules imported by require() as const, assuming they aren't reassigned?

@bnoordhuis
Copy link
Member

@cjihrig +1 from me, no reason not to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants