View Single Post
08-16-15, 10:36 AM   #20
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by Rilgamon View Post
Turn your logic around a little. The request was to improve the performance. And removing select will always be an improvement.
Sure, but I didn't read the word "performance" anywhere, only "better". If the performance gain is negligible I would definitely go for readability.

Edit: Without wanting to make a point of it, just did some quick benchmarks so people can get an idea of the difference.
This takes 43 ms to run:
Code:
for i = 1, 1e6 do
	local a, b, c = 1, 2, 3, 4, 5, 6, 7, 8, 9
end
This takes 94 ms to run, with the first select argument not affecting the result. No local reference.
Code:
for i = 1, 1e6 do
	local a, b, c = select(1, 1, 2, 3, 4, 5, 6, 7, 8, 9)
end
That's one million iterations, with each value adding a few ms in both tests.
__________________
Grab your sword and fight the Horde!

Last edited by Lombra : 08-16-15 at 10:55 AM.
  Reply With Quote