lua-users home
lua-l archive

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


Soni L. <fakedme@gmail.com>于2015年9月30日周三 上午8:45写道:
The registry, a table, is SLOW. Can we use upvalues instead?


You can use a thread as an array instead of upvalues. 

Use lua_newthread to create a new thread, hold L both in C and lua registry (prevent GC) ,
and then you can use lua C api directly to push values into that L . I think is better than use a table in registry or upvalues .
(Remember call lua_checkstack when you push values to thead )

I think the C API to manage stack of L is cheaper than registry . 

You can use lua_xmove to move all the values from thread into lua .