I noticed that the first function works faster than the second on luau, but in lua, on the contrary, method 2 is faster. Is it even worth using the first method in roblox?
local function m1(...)
for i = 1, select('#', ...) do
local value = select(i, ...)
end
end
local function m2(...)
for i, v in pairs{...} do
end
end
for luau, the first method is better in terms of memory allocation and processing speed. however, unless ur iterating through a very heavy table and doing heavy calculations, the difference is basically impossible to notice and useless.
Luau does a pretty damn good job at optimizing method 1!
On O0 (no optimizations), method 1 is many magnitudes slower (to the point where a game using this could be unplayable), but on O1 and above, import, fastcall and other optimizations seem to make it ever so slightly faster than method 2.