[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: void* in Lua_State for Application?
- From: Coda Highland <chighland@...>
- Date: Thu, 5 Sep 2013 09:43:58 -0700
On Thu, Sep 5, 2013 at 7:31 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> On Wed, Sep 4, 2013 at 8:33 PM, Tom N Harris <telliamed@whoopdedo.org> wrote:
>> > On Monday, September 02, 2013 03:14:08 PM Emil Renner Berthing wrote:
>> >> +LUA_API void (lua_setstatedata) (lua_State *L, void *sd);
>> >> +LUA_API void *(lua_getstatedata) (lua_State *L);
>> >
>> > What's the problem with storing a lightuserdata in the registry?
>>
>> Performance, mostly. That's a table lookup worth of overhead for every
>> function that needs to fetch it. A C function accessing a field in the
>> lua_State is substantially faster.
>
> Did you benchmark it for any real case (that is, a case that will waste
> some time doing something useful with the retrieved pointer)?
>
> -- Roberto
>
Actually I DO store a lightuserdata in the registry in my own code.
It's not performance-critical at all. I was only reflecting the OP's
rationale.
/s/ Adam