Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(transformer/async-generator-functions): simplify identifying…
… whether within an async generator function (#7170) Follow-on after stack up to #7148. Split `is_inside_async_generator_function` into 2 functions `yield_is_inside_async_generator_function` and `async_is_inside_async_generator_function`. There are a couple of differences between `yield` and `await`, which we can leverage to make both these functions simpler: * `yield` cannot appear at top level (there's no such thing as "top level yield"). * `yield` cannot appear in an arrow function (there's no such thing as a "generator arrow function"). In addition: * Because each function now handles a specific case, no need to check if function containing `async` is an async function. It must be. Ditto for `yield`. * Remove the `if ctx.current_scope_flags().is_top()` check. Probably this check costs more than it saves because top level `await` is far less common than `await` within async functions. So this check was optimizing for an uncommon case, at a cost to the common case. * Add more comments to explain the logic. This is all quite small optimizations, but I was having difficulty understanding the logic, and found that splitting it up made it clearer (at least for me).
- Loading branch information