Re: Faster tag methods
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Faster tag methods
- From: Roberto Ierusalimschy <roberto@...>
- Date: 2002年3月07日 09:13:04 -0300
> 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