-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Optimize async to generator #8267
Optimize async to generator #8267
Conversation
We can reuse the step function, avoiding a closure on every invocation.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/8498/ |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/8496/ |
@@ -238,30 +238,35 @@ helpers.asyncGeneratorDelegate = () => template.program.ast` | |||
`; | |||
|
|||
helpers.asyncToGenerator = () => template.program.ast` | |||
function step(gen, resolve, reject, _next, _throw, key, arg) { |
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 think it'd be worth giving this a more verbose name if we're splitting it out. Thoughts?
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.
Sure.
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.
cool thanks
|
||
_next(); | ||
_next(undefined); |
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.
any particular reason for this explicit undefined?
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.
Monomorphic calls. Probably negligible.
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.
is arg length important for monomorphism? always thought solely about shapes in this regard
We can reuse the step function, avoiding a closure on every invocation.