lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Aug 26, 2011 at 07:17:10PM +0200, Alexander Gladysh wrote:
> On Fri, Aug 26, 2011 at 21:09, Mike Pall <mikelu-1108@mike.de> wrote:
> >
> > pairs() will not be fast, no matter what I do.
> 
> So, any code that uses pairs() is bound to be interpreter-only, is this
> correct?
> 
pairs() traverses all actually used entries in a hash table.  Although
in theory it takes O(n) time to traverse n pairs, in practice the big-O
hides a fairly substantial factor compared to ipairs().  Even if you
hand-code everything directly in assembler (which LuaJIT nearly does).

Dirk