lua-users home
lua-l archive

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

hi list,

I have read this thread:

I'm wondering how to access table with string in a fast way in a C
module, since I have many string-access in my C module.

e.g. if we declare some helper function:

void my_rawgets(lua_State *L, int idx, int strid);
void my_rawsets(lua_State *L, int idx, int strid);

how could I define them and avoid hash computing and get right slot directly?

now I use a pointer->string map in registry, and in rawsets/rawgets, I
first use strid to get real string from registry, them use string to
access table with lua_rawget/lua_rawset.

My benchmarks shows use this way we can sightly faster than direct
pushstring + rawset/rawget. but it still slower than directly

I want Lua coder can use string key directly so I don't want get/set
my data with id directly.

is there any way to make faster table access with string keys?

Xavier Wang.