lua-users home
lua-l archive

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


Matthew P. Del Buono wrote:
> We index the registry for classifiers by string, so
> this was resulting in strings being created a lot, and a lot of
> getfield/setfield operations. I have already proposed the change to use
> a static char's address as the key instead of a string, and the latter
> problem of getfield/setfield should disappear when we are no longer
> hitting that border case in the application (there's not much that can
> be done about it).

Even faster is to use lua_rawgeti(). Either assign the indexes at
runtime with luaL_ref, or use fixed indexes and an extra lookup
table. Make sure the indexes are contiguous and start at 1 (for LJ2
it's ok to start at 0, too).

The fastest way is to store an identifying object (e.g. a metatable)
in an upvalue of the C function and compare it with lua_rawequal().
This can get a bit tedious if you need to check for more than one
id or need the upvalues for other things.

> Actually I wasn't getting that; I was getting a different warning instead:
> [TRACE --- config.lua:9 -- NYI: return to lower frame at config.lua:10]
> 
> But this appears rarely so I think it is a non-issue.

If it's not in an inner loop, then it probably doesn't matter. But
this NYI is high on my TODO list.

--Mike