lua-users home
lua-l archive

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


>Try again...

I heard you this first time, but just didn't have anything good to say.
I'll try anyway.

>Yes, I realize that. EXCEPT considering the tag method in C involved
>which has to do a bunch of string lookups in the string key version.
>
>So I would LIKE to stick with table.FieldNameX = x, but avoid having to
>do a bunch of string matching in C in the tag methods.

Ah, if your tag method is in C, then yes you'll have to send strings to Lua 
and they'll have to be interned. But have you profiled your application
and established that this is a bootleneck?

You could try to store the strings in the registry using numerical keys once,
and retrieve them later. Something like this 

enum {
	F_X = 100,
	F_Y,
	F_Z,
	...
}

lua_pushstring(L,"X"); lua_rawseti(L,LUA_REGISTRYINDEX,F_X);
...

in the tag method:

lua_rawgeti(L,LUA_REGISTRYINDEX,F_X)
lua_gettable(L,table);

to get table.X.
--lhf