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
perf: Improve @babel/types
builders
#15843
base: main
Are you sure you want to change the base?
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/55175/ |
fefb16e
to
bba3872
Compare
bba3872
to
4280c24
Compare
3c03dea
to
e112104
Compare
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.
Awesome performance numbers! I am in favor of landing this for Babel 8.
I'm wondering if maybe we can get even better numbers by inlining the validateInternal
calls directly in the builder functions, at least for "pupular" nodes (Identifier, BinaryExpression, UnaryExpression, LogicalExpresssion, VariableDeclarator, VariableDeclaration, ...)
|
||
for (const key of builderKeys) { | ||
const field = fields[key]; | ||
if (field != null) validateInternal(field, node, key, node[key]); |
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.
Does the validation for required field still work with this field != null
check?
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.
It will work, I just followed here to check ahead.
https://github.com/babel/babel/pull/15843/files#diff-04a0d87b83569ab9a9d94ee801346cf5443ecf057bf35f4836d4a259e882c8fcR39
But thanks to you, I found another problem, validateChild
was accidentally skipped. :)
Yes, performance gets better when we inline, but I'm not sure if that's the way to go since the size would increase a lot. current
|
Fixes #1, Fixes #2
Some discussion is needed.
Because it's a breaking change.
Ref: #13868
This PR makes
fields
andbuilderKeys
only lookup once on initialization.