Thread Tools Display Modes
Prev Previous Post   Next Post Next
01-17-11, 06:51 PM   #1
frogofdoom
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Oct 2005
Posts: 31
Optimization Question: Dealing with multiple returns

Warning: this is a fine point of optimization, and I suspect that the difference is purely academic.

That said, when you only need one of the returns from a function with multiple returns (i.e. return var1, var2; ), which of these is better, memory-wise and/or CPU-wise:

This one, which seems to be the preferred way of doing it now:
Code:
local someVar = select(2, SomeFunction())
or this one, which I used to see in older code:
Code:
local _, someVar = SomeFunction()
The only reason I'm asking is that I typically figure that avoiding function calls if you don't need them is a good idea, but most good code that I've looked at lately uses select().

I'd appreciate any light anyone can shed on this. Thanks in advance.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Optimization Question: Dealing with multiple returns


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off