lua-users home
lua-l archive

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


It was thus said that the Great Xmilia Hermit once stated:
> Hi,
> 
> I want to share a patch to optimize for-in loops for the pairs and 
> ipairs case. It is inspired by LuaJITs ITERN optimization and a similar 
> optimization in Luau.
> 
> It works by checking in the OP_TFORPREP opcode for the pairs and ipairs 
> case and use the to-be-closed slot for an index variable in the pairs 
> and a marker in the ipairs case.

  Is this safe?  I ask because I use the to-be-closed slot in a C module
[1] for use with pairs.

  -spc

[1]	https://github.com/spc476/lua-conmanorg/blob/98f37deafb43d5d59fe1f2039c3bfc5575fce202/src/fsys.c#L638