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/ |
| } | ||
| if (this.state.leadingComments.length === 0) { | ||
|
|
||
| if (elements.length === 0) { |
There was a problem hiding this comment.
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.
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.