-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
Lift var declarations to the loop initializer #290
Labels
Comments
for(var i=0;;){var j=foo;}
for(var i=0,j;;){j=foo;}
for(var i=0;;){var j=foo,k=bar;}
for(var i=0,j,k;;){j=foo,k=bar;}
// and we can stop at 2 or even 1
for(var i=0;;){var j=foo,k=bar,l=baz;}
for(var i=0,j,k,l;;){j=foo,k=bar,l=baz;} The gotcha I see here is the order of transformations. for (var i = 0;;) { var j = foo; var k = bar; }
|
We can do this as a part of merging-sibling-variables only ... and not worry about order. !!! |
@vigneshshanmugam sure, any help is welcome! |
kangax
added a commit
that referenced
this issue
Nov 27, 2016
lift var declarations to initializer (fix #290)
boopathi
pushed a commit
that referenced
this issue
Nov 27, 2016
fix a empty loop scenario add more tests and fixes handle for statments without block lift both var/let declarations move function out of ForStatment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, this code:
transforms to:
but if we lift var declarations to the loop, we can get it down to:
This becomes irrelevant with multiple declarations so we might only consider doing this in certain cases but not others:
transforms to:
and is same length with lifted:
The text was updated successfully, but these errors were encountered: