# HG changeset patch # User Matthew Wild # Date 1427799557 -3600 # Node ID 7c4cf87f4dff161817529481f4752b2f8ed2954b # Parent b6e558febb7af6605b744d4d623e73df0e510e7e util.table, Makefile: New C module that allows pre-allocation of tables to improve performance and decrease memory fragmentation diff -r b6e558febb7a -r 7c4cf87f4dff util-src/Makefile --- a/util-src/Makefile Fri Mar 27 22:19:44 2015 +0000 +++ b/util-src/Makefile Tue Mar 31 11:59:17 2015 +0100 @@ -14,9 +14,9 @@ .PHONY: all install clean .SUFFIXES: .c .o .so -all: encodings.so hashes.so net.so pposix.so signal.so +all: encodings.so hashes.so net.so pposix.so signal.so table.so -install: encodings.so hashes.so net.so pposix.so signal.so +install: encodings.so hashes.so net.so pposix.so signal.so table.so install *.so ../util/ clean: diff -r b6e558febb7a -r 7c4cf87f4dff util-src/table.c --- /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 +#include + +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; +}