lua-users home
lua-l archive

Re: Faster tag methods

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


> If you need to dynamically create some of the table fields, you can just
> spin your own hash table. With a good hash function, a good sized table,
> and collisions handled by linked lists, you'll probably never see more than
> one or two string compares.
Maybe you can find such hash table in Lua ;-) You can add the pairs
"string-key" -> "number->key" into the registry (or another table). Then,
when you enter your tag-method function, you do
 /* assuming that "string-key" is on the top (last parameter) */
 lua_rawget(L, LUA_REGISTRYINDEX);
 number_key = lua_tonumber(L, -1);
-- Roberto

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