lua-users home
lua-l archive

[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$$b$1"       |$$ ,`      ,$$"             ``'          $$
 ```"```'"    `"`         `""`        ""`                          ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'