regenerator
regenerator copied to clipboard
Transform ...rest parameters of generator functions more efficiently
As @maxnordlund points out in https://github.com/facebook/regenerator/issues/131, aliasing the arguments
object has negative performance consequences.
If you happen to transform ...rest
parameters into ES5 arguments
-style code earlier in your transformation pipeline than the Regenerator transform, Regenerator will currently capture the arguments
object and generate inefficient code that aliases the arguments
object in the outer function, only to turn it into an array in the inner function.
If Regenerator handled ...rest
parameters itself, then it could be smart about where the array conversion happened, and potentially avoid aliasing the arguments
object at all.
Regenerator should continue supporting all the exotic behavior of the arguments
object when you need it, but it would be great if the standard recommendation for improving arguments
performance was "just use a ...rest
parameter if possible!"
Hmm… but if Regenerator handles ...rest
parameters only for generator functions, then you'd still need to have a separate transform for all other ...rest
parameters, and you might still make the mistake of running that transform before Regenerator.
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.