lua-users home
lua-l archive

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


Roberto Ierusalimschy <roberto@inf.puc-rio.br> writes:
> Thanks for the info. How did you use the registry? Integer
> keys/lua_rawgeti?  String keys? (This message is for Miles Bader,
> too.)

I just used registry string entries at first because that's what the
various luaL_ functions make easy to use ... luaL_checkudata, etc.
Many existing libraries do things that way, so it was the natural way
to go.

But later when trying to optimize things, I tried upvalues instead,
and they were significantly faster.

It never occurred to me to try integer keys (or rawgeti), but as that
presents additional issues (e.g., one must come up with a system to
assign small-integer keys without conflicts), and has no particular
library support (luaL_checkudata etc), it seems like I may as well
just use upvalues when possible (and upvalues of course have the
advantage of being a local namespace, with no namespace conflict
issues).

[I will keep those techniques in mind for cases where I can't use
upvalues though!]

Thanks,

-miles

-- 
"I distrust a research person who is always obviously busy on a task."
   --Robert Frosch, VP, GM Research