I found a tweet yesterday, from M. J. Fromberger:
In case the picture doesn’t work for you, Mr Fromberger says:
There are only three optimizations: Do Less. Do it less often. Do it faster. The largest gains come from #1 but we spend all our time on #3.
I often see my friends and colleagues here obsessing over whether it’s more efficient to say
list L += [newItem];
or to say
list L = (L= + L) + [newItem];
Or something equally arcane. Now this is fun to know, and within reason, can be useful. Scripts in SL are certainly somewhat limited in size, and all the time they take adds up. Or does it?
You can do your own imaginary arithmetic to figure out the impact. And you sure can write your scripts any way you want to.
But listen to Mr Fromberger. The best thing to do is not to do something at all. Can we avoid a calculation somehow? Can we use an approximation to a complex calculation? Can we pull the constant part of a calculation outside a loop? These are where the real savings are, in my experience.
And what’s the best way to be in a position to notice those things, and to do them? Well, for me, it’s simple, clear code. I always write code as absolutely clearly as I can — subject to my limitations of intelligence, and the time I have available. When my code is clear, I’m more able to see what it’s doing, and to see ways to eliminate it, replace it with something better, or use it less often.
Just something to think about. You get to script as you wish, as do we all. Come visit my land and look at what’s going on there. Maybe it will give you some good ideas. Have fun!
Leave a Reply