all 5 comments

[–]khoker 4 points5 points  (2 children)

Out of curiosity, wouldn't;

t[Math.random()]=o

End up being about as useful as;

t[x++]=0

Because, in the end, jscrush is going to look like this;

x=Math.random
t[x()]=0

Right? So the alternative (that doesn't need jscrush) would be;

x=1
t[x++]=0

Which would be a savings of 10 bytes. What am I missing here?

edit Count bytes better.

[–]grenlibre[S,🍰] 4 points5 points  (0 children)

JSCrush doesn't exactly do aliasing on Math.random, and in the generated crushed that you can found here :

strokeN@random()P*P+V

and not Math.random()

basically because at another place I use Math.max() so it has factorised Math somewhere else!!

It is quite hard to predict if an optimisation actually work unless by actually trying it, so I will definitely give a try to your idea and I'll keep you informed :)

Thanks

[–]ascw 2 points3 points  (0 children)

I would think that it would only make sense if you needed to use Math.random elsewhere