View Single Post
01-18-12, 08:07 AM   #5
Barjack
A Black Drake
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 89
Originally Posted by Haleth View Post
I had an idea, not sure why I didn't think of this before - and I think it is what Barjack means also - it would be possible to use 3 different 'time since last update' values, check for each in one OnUpdate script and let them count to different numbers. That might be the most efficient, unless conditions actually require more instructions than a simple time/latency check.
That's how I was assuming the single-OnUpdate version would work, yeah. Something like

Code:
function someUpdateChecker (self, elapsed)
  local timer1 = timer1 + elapsed
  local timer2 = timer2 + elapsed
  if timer1 > limit1 then
    timer1 = 0
    doStuff1()
  end
  if timer2 > limit2 then
    timer2 = 0
    doStuff2()
  end
end
Which is what I assume is more efficient than a 3-function (or 2-function in this simplified example) alternative simply because it essentially is 3 different update functions, just all crammed into one. Perhaps you had something else in mind, though.

Naturally, as you said in the original post, the difference is probably undetectably minor. In fact, I wouldn't be surprised to learn that the speed of whatever has to manage SetScript callbacks etc. is slower than the actual difference here and therefore results in a slightly bigger difference overall.

Again, all completely untested etc.
  Reply With Quote