Skip to content

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

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.

4 participants