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

One little optimization for "refactor setInterval" feature #72

Closed
xem opened this issue Feb 18, 2017 · 3 comments
Closed

One little optimization for "refactor setInterval" feature #72

xem opened this issue Feb 18, 2017 · 3 comments
Assignees
Milestone

Comments

@xem
Copy link

xem commented Feb 18, 2017

Packing this example code with setInterval refactor and loop var "t":

t=0;setInterval(function(e){t++},33)

preprocessed code is:

if(!f){}f++

should be simplified to:

f++

packed code is:

for(_='if(!f){}f++';G=/[]/.exec(_);)with(_.split(G))_=join(shift(f=0));setInterval(_,33)

should be simplified to:

for(_='f++';G=/[]/.exec(_);)with(_.split(G))_=join(shift(f=0));setInterval(_,33)

cheers!

@Siorki
Copy link
Owner

Siorki commented Feb 18, 2017

You mean you do not have any initialization code ? That is, code that is run once before entering the loop. Is is an example from a real demo ?

I did not expect that case to happen, but it should be easy to solve.

@Siorki Siorki self-assigned this Feb 18, 2017
@xem
Copy link
Author

xem commented Feb 18, 2017

My real-life demo is very near from the example I sent above:

t=0;setInterval(function(){t?play():init();t++},33)

(with "play()" and "init()" replaced by big chunks of code.)

unfortunately, this packs as:

for(_='if(!t){}t?play():init();t++';G=/[]/.exec(_);)with(_.split(G))_=join(shift(t=0));setInterval(_,33)

I'm not asking you to support ternaries a?b:c, but if you could remove the if(!t){} fragment when the braces are empty, that'd be great.

@Siorki Siorki added this to the 5.0.1 milestone Feb 19, 2017
@Siorki
Copy link
Owner

Siorki commented Feb 20, 2017

Removed the code if(!f){} if there is no initialization code, neither at the beginning nor the end.
Adapted thermal view as well.

@Siorki Siorki closed this as completed Feb 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants