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

perf: always return void 0 as undefined node #10243

Merged
merged 1 commit into from Aug 1, 2019

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Jul 19, 2019

Q                       A
Fixed Issues?
Patch: Bug Fix? Performance tweak
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Effectively, this.hasBinding("undefined") will always returns true since undefined is a global property. As void 0 is safer than undefined, here we remove the if conditional check. buildUndefinedNode will be a bit faster as it doesn't have to look through the nested scopes.

I would also suggest that we move buildUndefinedNode to babel-types and clearly state that it is not relevant to the Scope class.

@JLHwung JLHwung changed the title perf: always return void 0 as undefined code perf: always return void 0 as undefined node Jul 19, 2019
@JLHwung JLHwung force-pushed the build-undefiend-without-scope branch from 74b5686 to ca44286 Compare July 19, 2019 17:56
@babel-bot
Copy link
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11182/

@nicolo-ribaudo
Copy link
Member

I would also suggest that we move buildUndefinedNode to babel-types and clearly state that it is not relevant to the Scope class.

Maybe in the next major?

@nicolo-ribaudo nicolo-ribaudo added the PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories label Jul 20, 2019
@JLHwung
Copy link
Contributor Author

JLHwung commented Jul 23, 2019

Maybe in the next major?

Sure. We would not get rid of it on 7.x

@nicolo-ribaudo nicolo-ribaudo merged commit 5fb4d84 into babel:master Aug 1, 2019
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 31, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 31, 2019
@JLHwung JLHwung deleted the build-undefiend-without-scope branch December 15, 2020 15:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants