Repository navigation
Shrink jsx helper size - #18325
Shrink jsx helper size#18325
Conversation
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/62639 |
|
commit: |
| ): ReactElement { | ||
| if (!REACT_ELEMENT_TYPE) { | ||
| REACT_ELEMENT_TYPE = | ||
| var elementType = |
There was a problem hiding this comment.
We don't need this intermediate variable; it makes it look like we get smaller code just because we don't minify top-level names. I opened #18397 for it.
There was a problem hiding this comment.
Thanks, I will revisit this PR once #18397 has been merged and see if I can still shrink the size a bit.
Assisted-by: Claude Opus 5.5
326657f to
0a70520
Compare
|
I have rebased this PR, the new changes are still smaller than the current build, though the gain is very marginal (1 byte less after gzip). |
| childArray = new Array(childrenLength); | ||
| for (var i = 0; i < childrenLength; i++) { | ||
| childArray[i] = arguments[i + 3]; | ||
| } |
There was a problem hiding this comment.
I’m not sure if .push is significantly slower, but it should help reduce the file size.
There was a problem hiding this comment.
I prompted LLM to test on Node.js 6 and confirm that crankshaft can optimize indexed access and push, but not [].slice.call on arguments, I will update to the push approach.
There was a problem hiding this comment.
Hmm, if we use .push here, the @babel/runtime-corejs3 will pull _pushInstanceProperty(a).call(a, arguments[i + 3]) here, for the time being I will leave it as-is.
In this PR we shrink the jsx helper size. The goal is to do it without behaviour changes and performance regression. Note that the
argumentloop could have been replaced by[].slice.call, but doing so yields 75% more running time than the current version.