Mercurial > prosody-hg
diff util-src/table.c @ 6610:7c4cf87f4dff
util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 31 Mar 2015 11:59:17 +0100 |
| parents | |
| children | 8e4572a642cb |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/util-src/table.c Tue Mar 31 11:59:17 2015 +0100 @@ -0,0 +1,14 @@ +#include <lua.h> +#include <lauxlib.h> + +static int Lcreate_table(lua_State* L) { + lua_createtable(L, luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)); + return 1; +} + +int luaopen_util_table(lua_State *L) { + lua_newtable(L); + lua_pushcfunction(L, Lcreate_table); + lua_setfield(L, -2, "create"); + return 1; +}
