Originally Posted by tehmoku
I would like to see your optimizations though. I threw it together pretty quick, and I can already see at least one thing I'd change, but I might as well optimize as much as I can if I'm going to handle the numbers myself (although I don't know if that's specifically worth it...)
|
The first thing that stood out to me was this line.
Code:
local timeLeft = start / 1000 + dur / 1000 - GetTime()
Currently, you're taking one variable, dividing by 1000, then taking another variable and doing the same before adding them together. You can save a divide operation by adding the variables together before dividing by 1000.
Code:
local timeLeft = (start + dur) / 1000 - GetTime()
A second thing I'd note is FontStrings have a built-in format function that works in the same way, you can save a global index and a function call by using it instead. Even if C code does the exact same thing, remember, C code processes much faster natively than Lua code can.
Code:
self.text:SetFormattedText("%d", timeLeft)
Again, and at the scale of once every 200ms, you're not really going to see a difference.