View Single Post
03-31-09, 04:46 PM   #31
Shadowed
...
Premium Member
Featured
Join Date: Feb 2006
Posts: 387
You guys are vastly over-complicating this, from a fun abstract random curiosity type of question sure, but for practical applications, all you really need to ask yourself is "Am I doing something really stupid?" The majority of the mistakes I see new people make are they create a static table every time a function is loaded instead of once on file load like you see below. Creating options tables only when needed instead of all the time as Slakah mentioned as well.

Code:
function foo()
     local staticColor = { r = 1.0, g = 1.0, b = 1.0 };
end
Where you can shift it up so it becomes

Code:
local staticColor = { r = 1.0, g = 1.0, b = 1.0 };
function foo()
end
So you only create one table instead of the same table every time the function is called.

Eggi touched on this, but always ask yourself what the function is doing. If you're writing a mod for checking if the player has a buff and warning them, efficiency is a good goal but you shouldn't worry about it; on the other hand, if you're writing a mod to monitor the auras of 25 people in a raid during combat, then efficiency should be something you care more about. If you it requires user interface (GUIs, and that kind of thing) or they can't do it in combat then efficiency should be a lot lower on your list.
  Reply With Quote