Skip to content

perf: always return void 0 as undefined node#10243

Merged
nicolo-ribaudo merged 1 commit intobabel:masterfrom
JLHwung:build-undefiend-without-scope
Aug 1, 2019
Merged

perf: always return void 0 as undefined node#10243
nicolo-ribaudo merged 1 commit intobabel:masterfrom
JLHwung:build-undefiend-without-scope

Conversation

@JLHwung
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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

@nicolo-ribaudo
Copy link
Copy Markdown
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
Copy Markdown
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