[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Iterate over vararg
- From: Philipp Janda <siffiejoe@...>
- Date: Thu, 20 Dec 2018 19:33:43 +0100
Am 20.12.18 um 12:55 schröbte Andrew Gierth:
"Gabriel" == Gabriel Bertilson <firstname.lastname@example.org> writes:
Gabriel> Then the closure receives an unused first argument and a
Gabriel> second argument i, and it returns the i-plus-one-th argument
Gabriel> to the original function (similar to the behavior of the
Gabriel> function returned by ipairs). Not sure if this is more or less
Gabriel> efficient memory-wise than using a table.
I don't see any obvious reason why it would be more efficient - creating
the closure is allocating an object, after all, and it seems that
closures with upvalues probably would be more overhead than tables. But
I've not tried it.
The table version is 40 bytes more expensive on x86_64 (probably a bit
more because there are two allocations for the table version and just
one for the C closure).