Skip to content
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

Merged
merged 2 commits into from
Jul 5, 2018

Conversation

jridgewell
Copy link
Member

We can reuse the step function, avoiding a closure on every invocation.

We can reuse the step function, avoiding a closure on every invocation.
@babel-bot
Copy link
Collaborator

babel-bot commented Jul 5, 2018

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/8498/

@babel-bot
Copy link
Collaborator

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) {
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

Copy link
Member

@xtuc xtuc left a 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);
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Monomorphic calls. Probably negligible.

Copy link
Member

@Andarist Andarist Jul 5, 2018

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

@jridgewell jridgewell merged commit e229ebb into babel:master Jul 5, 2018
@jridgewell jridgewell deleted the optimize-async-to-generator branch July 5, 2018 14:51
@hzoo hzoo added the PR: Internal 🏠 A type of pull request used for our changelog categories label Jul 5, 2018
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: perf outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants