View Single Post
04-15-13, 04:35 AM   #35
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
You're missing the point by a very large margin. The point is not that calling Function A can get you info faster than calling Function B under Circumstance X. The point is that calling a function at all is much slower than assigning an extra variable, and you should not call functions if you don't need to -- specifically, there is almost no reason to ever use select.

Using your example, you should not do this:

Code:
local textureIndex = select(3, GetMapLandmarkInfo(i))
if textureIndex == 128 then
   -- do something
end
Instead, you should do this:

Code:
local _, _, textureIndex = GetMapLandmarkInfo(i)
if textureIndex == 128 then
   -- do something
end
You can get the exact same information from the exact same function, without the overhead of a second function call that's completely unnecessary and does not affect the information obtained or the source of the information.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote