Skip to content

Miscellaneous perf tweak#10421

Merged
nicolo-ribaudo merged 3 commits intobabel:masterfrom
JLHwung:perf-misc
Sep 10, 2019
Merged

Miscellaneous perf tweak#10421
nicolo-ribaudo merged 3 commits intobabel:masterfrom
JLHwung:perf-misc

Conversation

@JLHwung
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
}
if (this.state.leadingComments.length === 0) {

if (elements.length === 0) {
Copy link
Copy Markdown
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
Copy Markdown
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.

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.

5 participants