Changeset

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 6608:b6e558febb7a
children 6611:65dd3770bcb0
files util-src/Makefile util-src/table.c
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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:
--- /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;
+}