[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua_newuserdatabox (4.1)
- From: Roberto Ierusalimschy <rieru@...>
- Date: Thu, 21 Feb 2002 10:04:24 -0600 (CST)
On Wed, 20 Feb 2002, Curt Carpenter wrote:
> I was curious as to why the naming of lua_newuserdatabox doesn't follow
> the same naming convention as all the lua_push* functions. Tracing
> though the code a bit, I was disappointed to discover that
> lua_newuserdatabox ends up causing a memory allocation. Can't we please
> have a lua_pushuserdata(lua_State *, void *) or the like? I know this
> has been discussed already, but at the time my (mis)understanding was
> that the new lua_newuserdatabox was lightweight. An allocation just to
> pass a simple pointer is going to kill performance. This is the kind of
> thing that could cause me to have to significantly scale back the scope
> I was planning for Lua to have in my project.
The old lua_pushuserdata also did memory allocation, when the pointer
was not already "inside" Lua. But, if you know that the pointer is
already inside Lua, usually you do not need to use lua_newuserdatabox,
but can use lua_pushvalue (or something similar). Those operations do
not do memory allocation.
-- Roberto