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

Miscellaneous perf tweak #10421

Merged
merged 3 commits into from Sep 10, 2019
Merged

Miscellaneous perf tweak #10421

merged 3 commits into from Sep 10, 2019

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Sep 9, 2019

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

Some miscellaneous performance tweak when reading comment attachment code.

@JLHwung JLHwung added the PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories label Sep 9, 2019
@babel-bot
Copy link
Collaborator

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

1 similar comment
@babel-bot
Copy link
Collaborator

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

@nicolo-ribaudo nicolo-ribaudo merged commit 4395c22 into babel:master Sep 10, 2019
return;
}
if (this.state.leadingComments.length === 0) {

if (elements.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised by this change. Checking an array's length should be much faster than accessing 3 props.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checking an array's length should be much faster than accessing 3 props.

True. This change is implemented from the code coverage result via running babel-parser on material-ui. There are 4000 exits from this.state.leadingComments.length === 0 but 400 exits on elements.length === 0, which means in real world it is more likely that we don't have leading comments than we have empty elements here.

@JLHwung JLHwung deleted the perf-misc branch September 10, 2019 20:30
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Dec 10, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 10, 2019
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

5 participants