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
Miscellaneous perf tweak #10421
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11529/ |
1 similar comment
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11529/ |
return; | ||
} | ||
if (this.state.leadingComments.length === 0) { | ||
|
||
if (elements.length === 0) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Some miscellaneous performance tweak when reading comment attachment code.