[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LuaJIT2 vs. vararg
- From: Mike Pall <mikelu-0911@...>
- Date: Wed, 25 Nov 2009 13:20:40 +0100
Alexander Gladysh wrote:
> I see. Would recursion without varargs be slow as well? (I'm asking this in
> general, not related to the arguments().)
In theory, recursion (without varargs) could be optimized as well
as any loop. In practice, it probably won't. Simply because few
real-world Lua code makes use of recursion for time-critical parts.
> The question is: can LJ2 be made to optimize the function below away?
> (That's what args_unroll_simple is.)
>
> local arguments = function(...)
> local n = select("#", ...)
> -- Assuming cache is pre-populated for all possible use-cases
> return assert(arguments_cache[n])(...)
> end
Yes, I'm pretty sure this can be optimized away. The only thing
preventing it right now is the varag function and select().
--Mike