lua-users home
lua-l archive

Re: Pushing a UserData pointer?

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


Mark Hamburg wrote:
This is more or less the way I ended up doing object pushes from
Objective-C. The one enhancement I came up with was to use a light userdata
instead of a pointer to get to the table.
 lua_pushlightuserdata(L, kObjectsTableKey);
 // kObjectsTableKey just needs to be a unique pointer
 lua_gettable(L, LUA_REGISTRYINDEX);
 lua_pushlightuserdata(L, this);
 lua_gettable(-2);
 lua_remove(-2);
Still not exactly cheap.
That's what I was doing originally. When I moved to the "hack" version, I doubled the speed of my test cases. It's not surprising. Looking at the two table lookups, I was having to go through a couple of hundred statements. Implementing lua_pushuserdata() dropped that down to about 8! Still a long way to go, but I'm getting closer. Thanks for the suggestions...
--
chris marrin ,"",ドル
cmarrin@arch.sel.sony.com b` $ ,,.
(408) 955-3049 mP b' , 1$'
Sony ,.` ,b` ,` :$$'
 ,|` mP ,` ,mm
 ,b" b" ,` ,mm m$$ ,m ,`P$$
 m$` ,b` .` ,mm ,'|$P ,|"1$` ,b$P ,` :1ドル
 b$` ,$: :,`` |$$ ,` $$` ,|` ,$,,ドル`"$$ .` :$|
b$| _m$`,:` :1ドル ,` ,$Pm|` ` :$,ドル..;"' |$:
P$b, _;b$$b1ドル" |$$ ,` ,$$" ``' $$
 ```"```'" `"` `""` ""` ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'

AltStyle によって変換されたページ (->オリジナル) /