[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: explicitly defining table length + _ARG proposal
- From: Mark Hamburg <mark@...>
- Date: Fri, 2 Jul 2010 07:40:57 -0700
A smart optimizer could recognize the following and optimize them to avoid the likely n-squared costs:
select( '#', ... )
select( i, ... ) -- to a context wanting only a specific number of values
Of course, the optimizer would also have to recognize that select hadn't changed from its default, so we're pretty clearly in the sort of optimization territory pursued by LuaJIT.
For the simple iteration case, the following would be useful:
for i, v in ivalues( ... ) do
-- code
end
[ Note that the the fact that returning nil stops the iteration means we can't just have values( ... ). I view this as defect in the definition of the generic for loop since one could use returning nothing as the appropriate indicator. That would, however, probably break a lot of existing iterator functions. ]
ivalues could even be optimized for the zero and one value cases to stick the value into the state parameter and return an appropriate iterator function. Beyond that, however, one is at the mercy of the speed of the allocator and collector.
Mark