[m-users.] Question about any difference in efficiency on this code...
Sean Charles (emacstheviking)
objitsu at gmail.com
Sat Aug 26 20:12:53 AEST 2023
I started out with this:
get_random_value(0, 2, V, !IO),
( if V = 0 then
Speed = 0.25, Color = color(gray)
else if V = 1 then
Speed = 0.75, Color = color(skyblue)
else
Speed = 1.25, Color = color(beige)
),
Star = star(X, StarY, Speed, to_rgba(Color)).
end then, for some half0baked reason regarding not creating Speed and Color but instead directly returning Star...
get_random_value(0, 2, V, !IO),
( if V = 0 then
Star = star(X, StarY, 0.25, to_rgba(color(gray)))
else if V = 1 then
Star = star(X, StarY, 0.75, to_rgba(color(skyblue)))
else
Star = star(X, StarY, 1.25, to_rgba(color(beige)))
).
So, is there any real difference, or did I do something good / bad / indifferent at best?
Yes, I know it's a nit picking question but I am curious to know the relative speed / efficiencies , I am writing a game after all so being 1980-s paranoid, every cycle counts. I have '-O4' level optimisation in my build.
:D
Thanks
Sean.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20230826/cb7ebbe6/attachment.html>
More information about the users
mailing list