[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Fast C string key access for table?
- From: Xavier Wang <weasley.wx@...>
- Date: Tue, 23 Apr 2013 09:13:49 +0800
hi list,
I have read this thread: http://lua-users.org/lists/lua-l/2013-03/msg00893.html
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
rawsetp/rawgetp.
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?
--
regards,
Xavier Wang.