From 856c775316dbcdba36acfab1a3c300b0372d8ecf Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 31 Dec 2015 15:33:13 +0100 Subject: support only LuaJIT and use some additional (insignificant) optimizations --- Makefile | 7 ------- applause.c | 8 ++++++++ applause.lua | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index ceb7ff8..999fac3 100644 --- a/Makefile +++ b/Makefile @@ -2,15 +2,8 @@ CC = gcc CFLAGS = -std=c99 -Wall -O2 -LUAJIT = yes - -ifeq ($(LUAJIT),yes) LUA_CFLAGS = $(shell pkg-config --cflags luajit) LUA_LDFLAGS = $(shell pkg-config --libs luajit) -else -LUA_CFLAGS = $(shell pkg-config --cflags lua5.1) -LUA_LDFLAGS = $(shell pkg-config --libs lua5.1) -endif READLINE_CFLAGS = READLINE_LDFLAGS = -lreadline -lhistory diff --git a/applause.c b/applause.c index a1af0f3..1097447 100644 --- a/applause.c +++ b/applause.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -493,6 +494,13 @@ l_Stream_play(lua_State *L) /* the tick generator function should now be on top of the stack */ luaL_checktype(L, -1, LUA_TFUNCTION); + /* + * Make sure JIT compilation is turned on for the generator function + * and all subfunctions. + * This should not be necessary theoretically. + */ + luaJIT_setmode(L, -1, LUAJIT_MODE_ALLFUNC | LUAJIT_MODE_ON); + /* * Perform garbage collection cycle and turn it off * temporarily. This improves the realtime properties diff --git a/applause.lua b/applause.lua index c701bc3..644c23d 100644 --- a/applause.lua +++ b/applause.lua @@ -2,7 +2,7 @@ local sndfile = require "sndfile" local ffi = require "ffi" local bit = require "bit" --- Make table.new() available +-- Make table.new() available (a LuaJIT extension) require "table.new" -- @@ -336,7 +336,7 @@ function Stream:totable() end local tick = self:tick() - local vector = {} + local vector = table.new(self:len(), 0) while true do local value = tick() -- cgit v1.2.3