lua-users home
lua-l archive

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


On Thu, Mar 24, 2011 at 21:34, Jerome Vuarand <jerome.vuarand@gmail.com> wrote:
> 2011/3/24 Alexander Gladysh <agladysh@gmail.com>:
>> On Thu, Mar 24, 2011 at 20:40, Jerome Vuarand <jerome.vuarand@gmail.com> wrote:

>>> Just use it as a key in the module
>>> table, which you previously set as all your lua_CFunction-s
>>> environment:

>>> {
>>>  const char* redis_result;
>>>  ... /* get a value for redis_result */
>>>  lua_getfield(L, LUA_ENVIRONINDEX, redis_result);
>>>  return 1;
>>> }

>> Looks like that, with some metatable magic, I even can create status
>> userdata on demand and not bother with pre-caching it.

> This qualifies as premature optimization too ;-)

> If you only have a few status codes, the metatable + metamethod
> creation may just cost more that pre-caching the values.

No, that is not about the speed here. I think that, probably, this
will make the code look better. We'll see :-)

Alexander.