[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: reusing objects for tight iteration loops
- From: David Favro <lua@...>
- Date: Thu, 30 Jan 2014 21:05:45 -0500
Rather than trying so hard to make it seem like it's actually a new row, I
think you're better off to just document for your users that it is the same
table re-used: either they can copy it if necessary, or you can offer two
versions of the iterator, one which is optimized and one "traditional".
Other than that, you could adapt the idea presented here to get a speed-up
of the every-row-is-a-new-table version:
http://lua-users.org/lists/lua-l/2012-12/msg00613.html
But, beware of users who try to iterate over the items of the row using
pairs(): you can handle this in 5.2 with __pairs, but in 5.1 it won't be easy.
-- David