lua-users home
lua-l archive

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

somewhere in my wrapper I have to clear some values from the registry.
When I have to clear the values, I don't know if the values were stored
in the registry or not.

So my questions are:

a.) Which one will fragment the registry lesser?
b.) Is version_B worth the effort?
c.) Or is version_A just enough because lua_rawset behaves intelligently?


~    void version_A(lua_State * L, void * key)
~    {
~      lua_pushlightuserdata(L, key);
~      lua_pushnil(L);
~      lua_rawset(L, LUA_REGISTRYINDEX);
~    }


~    void version_B(lua_State * L, void * key)
~    {
~      lua_pushlightuserdata(L, key);
~      lua_rawget(L, LUA_REGISTRYINDEX);
~      if (!lua_isnil(L, -1))
~      {
~        lua_pushlightuserdata(L, key);
~        lua_pushnil(L);
~        lua_rawset(L, LUA_REGISTRYINDEX);
~      }
~      lua_pop(L, 1);
~    }


-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBD614SIrOxc3jOmoRApCHAJ4i9GEbHmJAHuQcuxY0nC7XOs5lggCgmMKc
1J8vTt0JzH8XK3m/R9ebtrU=
=3dbK
-----END PGP SIGNATURE-----