lua-users home
lua-l archive

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


> The registry, a table, is SLOW. Can we use upvalues instead?

upvalues plus C function is closure which is Lua value not C value.
So  how you plan call this closure from C code. E.g. you have function
which  wrap C handle/buffer to Lua object

`int mylib_push_object(lua_State, void *handle)`

How you plan find closure/metatable without any Lua table (global/registry)?
Registry is better than global.
But  using  registry  to  store  all  library data is not necessary. I
prefer  use  my  own  table  which  stores  as  upvalue in all library
functions and store this table in Lua registry to be able access to it
from  C  code.  I use lightuserdata as key not luaL_ref because to use
luaL_ref in multi threaded environment it require uses some TLS.



---
Это сообщение проверено на вирусы антивирусом Avast.
https://www.avast.com/antivirus